Top Description Inners Fields Constructors Methods
org.apache.commons.collections4.trie

public abstract Class AbstractBitwiseTrie<K, V>

extends AbstractMap<K, V>
implements Trie<K, V>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.collections4.Trie, org.apache.commons.collections4.IterableSortedMap, org.apache.commons.collections4.OrderedMap, org.apache.commons.collections4.IterableMap, org.apache.commons.collections4.IterableGet, org.apache.commons.collections4.Get, org.apache.commons.collections4.Put, java.util.Map, java.util.SortedMap, java.util.SequencedMap
Known Direct Subclasses
org.apache.commons.collections4.trie.AbstractPatriciaTrie
Type Parameters
<K>
the type of the keys in this map
<V>
the type of the values in this map
Imports
java.io.Serializable, java.util.AbstractMap, .Map, .Map.Entry, org.apache.commons.collections4.Trie

This class provides some basic Trie functionality and utility methods for actual bitwise Trie implementations.
Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv abstract static class
AbstractBitwiseTrie.BasicEntry<K, V>

A basic implementation of Entry.

Field Summary

Modifier and TypeField and Description
private final KeyAnalyzer<? super K>
keyAnalyzer

The KeyAnalyzer that's being used to build the PATRICIA Trie.

private static final long

Constructor Summary

AccessConstructor and Description
protected
AbstractBitwiseTrie(final KeyAnalyzer<? super K>
the KeyAnalyzer to use
keyAnalyzer
)

Constructs a new Trie using the given KeyAnalyzer.

Method Summary

Modifier and TypeMethod and Description
pack-priv final int
bitIndex(final K key, final K foundKey)

Utility method for calling KeyAnalyzer#bitIndex(Object, int, int, Object, int, int).

pack-priv final int
bitsPerElement()

Returns the number of bits per element in the key

pack-priv final K
castKey(final Object key)

A utility method to cast keys.

pack-priv static boolean
compare(final Object a, final Object b)

Returns true if both values are either null or equal.

pack-priv final boolean
compareKeys(final K key, final K other)

An utility method for calling KeyAnalyzer#compare(Object, Object)

protected KeyAnalyzer<? super K>

Returns:

the KeyAnalyzer used by this Trie
getKeyAnalyzer
()

Returns the KeyAnalyzer that constructed the Trie.

pack-priv final boolean
isBitSet(final K key, final int bitIndex, final int lengthInBits)

Returns whether or not the given bit on the key is set or false if the key is null.

pack-priv final int
lengthInBits(final K key)

Returns the length of the given key in bits

public String
toString()

Overrides java.util.AbstractMap.toString.

Returns a string representation of this map.
Inherited from java.util.AbstractMap:
clearclonecontainsKeycontainsValueentrySetequalsgethashCodeisEmptykeySetputputAllremovesizevalues

Field Detail

keyAnalyzerback to summary
private final KeyAnalyzer<? super K> keyAnalyzer

The KeyAnalyzer that's being used to build the PATRICIA Trie.

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

AbstractBitwiseTrieback to summary
protected AbstractBitwiseTrie(final KeyAnalyzer<? super K> keyAnalyzer)

Constructs a new Trie using the given KeyAnalyzer.

Parameters
keyAnalyzer:KeyAnalyzer<? super K>

the KeyAnalyzer to use

Method Detail

bitIndexback to summary
pack-priv final int bitIndex(final K key, final K foundKey)

Utility method for calling KeyAnalyzer#bitIndex(Object, int, int, Object, int, int).

bitsPerElementback to summary
pack-priv final int bitsPerElement()

Returns the number of bits per element in the key

See Also
KeyAnalyzer#bitsPerElement()
castKeyback to summary
pack-priv final K castKey(final Object key)

A utility method to cast keys. It actually doesn't cast anything. It's just fooling the compiler!

Annotations
@SuppressWarnings:unchecked
compareback to summary
pack-priv static boolean compare(final Object a, final Object b)

Returns true if both values are either null or equal.

compareKeysback to summary
pack-priv final boolean compareKeys(final K key, final K other)

An utility method for calling KeyAnalyzer#compare(Object, Object)

getKeyAnalyzerback to summary
protected KeyAnalyzer<? super K> getKeyAnalyzer()

Returns the KeyAnalyzer that constructed the Trie.

Returns:KeyAnalyzer<? super K>

the KeyAnalyzer used by this Trie

isBitSetback to summary
pack-priv final boolean isBitSet(final K key, final int bitIndex, final int lengthInBits)

Returns whether or not the given bit on the key is set or false if the key is null.

See Also
KeyAnalyzer#isBitSet(Object, int, int)
lengthInBitsback to summary
pack-priv final int lengthInBits(final K key)

Returns the length of the given key in bits

See Also
KeyAnalyzer#lengthInBits(Object)
toStringback to summary
public String toString()

Overrides java.util.AbstractMap.toString.

Doc from java.util.AbstractMap.toString.

Returns a string representation of this map. The string representation consists of a list of key-value mappings in the order returned by the map's entrySet view's iterator, enclosed in braces ("{}"). Adjacent mappings are separated by the characters ", " (comma and space). Each key-value mapping is rendered as the key followed by an equals sign ("=") followed by the associated value. Keys and values are converted to strings as by String#valueOf(Object).

Returns:String

a string representation of this map

Annotations
@Override
org.apache.commons.collections4.trie back to summary

pack-priv abstract Class AbstractBitwiseTrie.BasicEntry<K, V>

extends Object
implements Map.Entry<K, V>, Serializable
Class Inheritance
  • java.lang.Object
  • org.apache.commons.collections4.trie.AbstractBitwiseTrie.BasicEntry
All Implemented Interfaces
java.io.Serializable, java.util.Map.Entry
Known Direct Subclasses
org.apache.commons.collections4.trie.AbstractPatriciaTrie.TrieEntry

A basic implementation of Entry.

Field Summary

Modifier and TypeField and Description
protected K
private static final long
protected V

Constructor Summary

AccessConstructor and Description
public
BasicEntry(final K key)

public
BasicEntry(final K key, final V value)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object
object to be compared for equality with this map entry
o
)

Overrides java.lang.Object.equals.

Implements java.util.Map.Entry.equals.

Compares the specified object with this entry for equality.
public K
getKey()

Implements java.util.Map.Entry.getKey.

Returns the key corresponding to this entry.
public V
getValue()

Implements java.util.Map.Entry.getValue.

Returns the value corresponding to this entry.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.Entry.hashCode.

Returns the hash code value for this map entry.
public V
setKeyValue(final K key, final V value)

Replaces the current key and value with the provided key & value.

public V
setValue(final V
new value to be stored in this entry
value
)

Implements java.util.Map.Entry.setValue.

Replaces the value corresponding to this entry with the specified value (optional operation).
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

keyback to summary
protected K key
serialVersionUIDback to summary
private static final long serialVersionUID
valueback to summary
protected V value

Constructor Detail

BasicEntryback to summary
public BasicEntry(final K key)
BasicEntryback to summary
public BasicEntry(final K key, final V value)

Method Detail

equalsback to summary
public boolean equals(final Object o)

Overrides java.lang.Object.equals.

Implements java.util.Map.Entry.equals.

Doc from java.util.Map.Entry.equals.

Compares the specified object with this entry for equality. Returns true if the given object is also a map entry and the two entries represent the same mapping. More formally, two entries e1 and e2 represent the same mapping if

    (e1.getKey()==null ?
     e2.getKey()==null : e1.getKey().equals(e2.getKey()))  &&
    (e1.getValue()==null ?
     e2.getValue()==null : e1.getValue().equals(e2.getValue()))
This ensures that the equals method works properly across different implementations of the Map.Entry interface.
Parameters
o:Object

object to be compared for equality with this map entry

Returns:boolean

true if the specified object is equal to this map entry

Annotations
@Override
getKeyback to summary
public K getKey()

Implements java.util.Map.Entry.getKey.

Doc from java.util.Map.Entry.getKey.

Returns the key corresponding to this entry.

Returns:K

the key corresponding to this entry

Annotations
@Override
getValueback to summary
public V getValue()

Implements java.util.Map.Entry.getValue.

Doc from java.util.Map.Entry.getValue.

Returns the value corresponding to this entry. If the mapping has been removed from the backing map (by the iterator's remove operation), the results of this call are undefined.

Returns:V

the value corresponding to this entry

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.Entry.hashCode.

Doc from java.util.Map.Entry.hashCode.

Returns the hash code value for this map entry. The hash code of a map entry e is defined to be:

    (e.getKey()==null   ? 0 : e.getKey().hashCode()) ^
    (e.getValue()==null ? 0 : e.getValue().hashCode())
This ensures that e1.equals(e2) implies that e1.hashCode()==e2.hashCode() for any two Entries e1 and e2, as required by the general contract of Object.hashCode.
Returns:int

the hash code value for this map entry

Annotations
@Override
setKeyValueback to summary
public V setKeyValue(final K key, final V value)

Replaces the current key and value with the provided key & value.

setValueback to summary
public V setValue(final V value)

Implements java.util.Map.Entry.setValue.

Doc from java.util.Map.Entry.setValue.

Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator's remove operation).

Parameters
value:V

new value to be stored in this entry

Returns:V

old value corresponding to the entry

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override