Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
commons-collections4-4.2-sources.jar - Apache Commons Collections
commons-collections4-4.2-sources.jar is the source JAR file for Apache Commons Collections 4.2, which provides additional collection handling functionalities on top of JDK library.
JAR File Size and Download Location:
JAR name: commons-collections4-4.2-sources.jar Target JDK version: 1.7 Dependency: None File size: 708,599 bytes Release date: 08-Jul-2018 Download: Apache Commons Collections
✍: FYIcenter.com
⏎ org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.collections4.trie.analyzer; import org.apache.commons.collections4.trie.KeyAnalyzer; /** * An {@link KeyAnalyzer} for {@link String}s. * * @since 4.0 */ public class StringKeyAnalyzer extends KeyAnalyzer<String> { private static final long serialVersionUID = -7032449491269434877L; /** A singleton instance of {@link StringKeyAnalyzer}. */ public static final StringKeyAnalyzer INSTANCE = new StringKeyAnalyzer(); /** The number of bits per {@link Character}. */ public static final int LENGTH = Character.SIZE; /** A bit mask where the first bit is 1 and the others are zero. */ private static final int MSB = 0x8000; /** Returns a bit mask where the given bit is set. */ private static int mask(final int bit) { return MSB >>> bit; } @Override public int bitsPerElement() { return LENGTH; } @Override public int lengthInBits(final String key) { return key != null ? key.length() * LENGTH : 0; } @Override public int bitIndex(final String key, final int offsetInBits, final int lengthInBits, final String other, final int otherOffsetInBits, final int otherLengthInBits) { boolean allNull = true; if (offsetInBits % LENGTH != 0 || otherOffsetInBits % LENGTH != 0 || lengthInBits % LENGTH != 0 || otherLengthInBits % LENGTH != 0) { throw new IllegalArgumentException("The offsets and lengths must be at Character boundaries"); } final int beginIndex1 = offsetInBits / LENGTH; final int beginIndex2 = otherOffsetInBits / LENGTH; final int endIndex1 = beginIndex1 + lengthInBits / LENGTH; final int endIndex2 = beginIndex2 + otherLengthInBits / LENGTH; final int length = Math.max(endIndex1, endIndex2); // Look at each character, and if they're different // then figure out which bit makes the difference // and return it. char k = 0, f = 0; for(int i = 0; i < length; i++) { final int index1 = beginIndex1 + i; final int index2 = beginIndex2 + i; if (index1 >= endIndex1) { k = 0; } else { k = key.charAt(index1); } if (other == null || index2 >= endIndex2) { f = 0; } else { f = other.charAt(index2); } if (k != f) { final int x = k ^ f; return i * LENGTH + Integer.numberOfLeadingZeros(x) - LENGTH; } if (k != 0) { allNull = false; } } // All bits are 0 if (allNull) { return KeyAnalyzer.NULL_BIT_KEY; } // Both keys are equal return KeyAnalyzer.EQUAL_BIT_KEY; } @Override public boolean isBitSet(final String key, final int bitIndex, final int lengthInBits) { if (key == null || bitIndex >= lengthInBits) { return false; } final int index = bitIndex / LENGTH; final int bit = bitIndex % LENGTH; return (key.charAt(index) & mask(bit)) != 0; } @Override public boolean isPrefix(final String prefix, final int offsetInBits, final int lengthInBits, final String key) { if (offsetInBits % LENGTH != 0 || lengthInBits % LENGTH != 0) { throw new IllegalArgumentException( "Cannot determine prefix outside of Character boundaries"); } final String s1 = prefix.substring(offsetInBits / LENGTH, lengthInBits / LENGTH); return key.startsWith(s1); } }
⏎ org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java
Or download all of them as a single archive file:
File name: commons-collections4-4.2-sources.jar File size: 708599 bytes Release date: 2018-07-08 Download
⇒ Download and Install commons-collections4-4.1-bin.zip
⇐ What Is commons-collections4-4.2.jar
2023-03-28, 27600👍, 0💬
Popular Posts:
maven-settings-builder-3 .8.6.jaris the JAR file for Apache Maven 3.8.6 Settings Builder module. Apa...
JDK 11 java.base.jmod is the JMOD file for JDK 11 Base module. JDK 11 Base module compiled class fil...
JDK 11 java.xml.jmod is the JMOD file for JDK 11 XML (eXtensible Markup Language) module. JDK 11 XML...
How to download and install xml-commons External Source Package? The source package contains Java so...
JDK 11 java.sql.rowset.jmod is the JMOD file for JDK 11 SQL Rowset module. JDK 11 SQL Rowset module ...