com.firefly.utils.collection.Trie Maven / Gradle / Ivy
package com.firefly.utils.collection;
import java.nio.ByteBuffer;
import java.util.Set;
/**
* A Trie String lookup data structure.
*
* @param the element of entry
*/
public interface Trie {
/**
* Put and entry into the Trie
*
* @param s
* The key for the entry
* @param v
* The value of the entry
* @return True if the Trie had capacity to add the field.
*/
public boolean put(String s, V v);
/**
* Put a value as both a key and a value.
*
* @param v
* The value and key
* @return True if the Trie had capacity to add the field.
*/
public boolean put(V v);
public V remove(String s);
/**
* Get and exact match from a String key
*
* @param s
* The key
*
* @return The value or null if not found
*/
public V get(String s);
/**
* Get and exact match from a String key
*
* @param s
* The key
* @param offset
* The offset within the string of the key
* @param len
* the length of the key
*
* @return The value or null if not found
*/
public V get(String s, int offset, int len);
/**
* Get and exact match from a segment of a ByteBuufer as key
*
* @param b
* The buffer
* @return The value or null if not found
*/
public V get(ByteBuffer b);
/**
* Get and exact match from a segment of a ByteBuufer as key
*
* @param b
* The buffer
* @param offset
* The offset within the buffer of the key
* @param len
* the length of the key
* @return The value or null if not found
*/
public V get(ByteBuffer b, int offset, int len);
/**
* Get the best match from key in a String.
*
* @param s
* The string
* @return The value or null if not found
*/
public V getBest(String s);
/**
* Get the best match from key in a String.
*
* @param s
* The string
* @param offset
* The offset within the string of the key
* @param len
* the length of the key
* @return The value or null if not found
*/
public V getBest(String s, int offset, int len);
/**
* Get the best match from key in a byte array. The key is assumed to by
* ISO_8859_1 characters.
*
* @param b
* The buffer
* @param offset
* The offset within the array of the key
* @param len
* the length of the key
* @return The value or null if not found
*/
public V getBest(byte[] b, int offset, int len);
/**
* Get the best match from key in a byte buffer. The key is assumed to by
* ISO_8859_1 characters.
*
* @param b
* The buffer
* @param offset
* The offset within the buffer of the key
* @param len
* the length of the key
* @return The value or null if not found
*/
public V getBest(ByteBuffer b, int offset, int len);
public Set keySet();
public boolean isFull();
public boolean isCaseInsensitive();
}