# Class: com.pnfsoftware.jeb.util.collect.CFBytesTrie

A trie map specialized to handle context\-free \(CF\) binary strings. Context\-free here means that the binary strings stored as keys cannot be such that, given a binary string A, there exists a longer binary string B whose prefix is A. 

 Characteristics/limitations:
 \- Support for insertion and retrieval only \(no removal\).
 \- The null key and the empty key are illegal.
 \- Null values are illegal.
 

 This class is not thread\-safe. This class does not override equals/hashCode/toString. 

 Implementation notes: this class is serializable \(provided that the stored objects T are also serializable\). In order to serialize this class efficiently, both in terms of space and time, a [key extractor](#setKeyExtractor(IKeyExtractor)) should be set.

## Constructor: CFBytesTrie

Description: Create an empty trie.

## Method: clear

Description: Remove all entries.

## Method: formatInternalState
- return type: `java.lang.String`

Description: Format internal trie statistics.
return: formatted state string

## Method: get
- parameter: `key`, type: `byte[]`
- parameter: `exactKey`, type: `boolean`
- return type: `T`

Description: Retrieve a value in the trie.
parameter: key: key
parameter: exactKey: true to require an exact key match
return: object value, null if none

## Method: get
- parameter: `keyarray`, type: `byte[]`
- parameter: `start`, type: `int`
- parameter: `max`, type: `int`
- parameter: `exactKey`, type: `boolean`
- return type: `T`

Description: Retrieve a value in the trie.
parameter: keyarray: key array
parameter: start: key start index
parameter: max: key end index \(exclusive\)
parameter: exactKey: if false, more potential key bytes may be provided, and the object whose key            matches the beginning of the sequence of bytes will be returned
return: object value, null if none

## Method: getItems
- return type: `java.util.List<com.pnfsoftware.jeb.util.base.Couple<byte[],T>>`

Description: Generate the list of items \(key, value\) stored in this trie. This method is potentially expensive.
return: list of stored key\-value pairs

## Method: getKeyExtractor
- return type: `com.pnfsoftware.jeb.util.collect.CFBytesTrie.IKeyExtractor<T>`

Description: 
return: configured key extractor, or null

## Method: getValues
- return type: `java.util.List<T>`

Description: Generate a list of all values stored in this trie. This method is potentially expensive.
return: list of stored values

## Method: isEmpty
- return type: `boolean`

Description: 
return: true if the trie is empty

## Method: put
- parameter: `object`, type: `T`

Description: Add a new entry to the trie. This method throws an [IllegalStateException](IllegalStateException) on prefix collision.
parameter: object: value \(the value's key is derived using the key extractor\)

## Method: put
- parameter: `key`, type: `byte[]`
- parameter: `object`, type: `T`

Description: Add a new entry to the trie. This method throws an [IllegalStateException](IllegalStateException) on prefix collision.
parameter: key: key
parameter: object: value

## Method: put
- parameter: `keyarray`, type: `byte[]`
- parameter: `start`, type: `int`
- parameter: `end`, type: `int`
- parameter: `object`, type: `T`
- return type: `T`

Description: Add a new entry to the trie. This method throws an [IllegalStateException](IllegalStateException) on prefix collision.
parameter: keyarray: key array
parameter: start: key start position in the array
parameter: end: key end position \(exclusive\)
parameter: object: value
return: the previous entry at key, null if none

## Method: putSafe
- parameter: `keyarray`, type: `byte[]`
- parameter: `start`, type: `int`
- parameter: `end`, type: `int`
- parameter: `object`, type: `T`
- parameter: `aprev`, type: `T[]`
- return type: `boolean`

Description: Add a new entry to the trie. This method does not throw if a prefix collision is detected; instead, false is returned.
parameter: keyarray: key array
parameter: start: key start position in the array
parameter: end: key end position \(exclusive\)
parameter: object: value
parameter: aprev: if non\-null, a one\-element array that will receive the previous entry at key, or            null if none
return: success indicator \(false if a prefix collision occurred\)

## Method: setKeyExtractor
- parameter: `keyExtractor`, type: `com.pnfsoftware.jeb.util.collect.CFBytesTrie.IKeyExtractor<T>`

Description: Set the key extractor used by [#put(Object)](#put(Object)) and optimized serialization.
parameter: keyExtractor: key extractor

## Method: size
- return type: `int`

Description: 
return: number of entries

