public class StringTrie_2<E> extends StringTrie<E>
| Modifier and Type | Class and Description |
|---|---|
protected class |
StringTrie_2.Edge
Our Edge class is one node in the Trie graph.
|
StringTrie.TrieEdge| Modifier and Type | Field and Description |
|---|---|
protected StringTrie_2.Edge |
root |
| Constructor and Description |
|---|
StringTrie_2() |
| Modifier and Type | Method and Description |
|---|---|
void |
compress(CharPoolTrie charPoolTrie) |
protected void |
doPut(StringTrie_2.Edge into,
char[] key,
int index,
int end,
E value) |
E |
get(char[] key) |
E |
get(char[] key,
int pos,
int end) |
E |
get(Chars keys,
int pos,
int end) |
E |
get(String key) |
protected Object |
lock(StringTrie_2.Edge into,
boolean ownsParent) |
protected StringTrie_2.Edge |
newEdgeGreater(StringTrie_2.Edge previous,
int keyMax,
char[] existing,
int matchesTo,
char[] key,
int keyIndex,
int keyEnd,
E value) |
protected StringTrie_2.Edge |
newEdgeLesser(StringTrie_2.Edge previous,
int keyMax,
char[] existing,
int matchesTo,
char[] key,
int keyIndex,
int keyEnd,
E value) |
protected E |
onEmpty(StringTrie_2.Edge e,
Chars keys,
int pos,
int end) |
void |
put(char[] key,
int start,
int end,
E value) |
void |
put(String key,
E value) |
protected E |
returnValue(StringTrie_2.Edge e,
Chars keys,
int pos,
int end) |
String |
toString() |
protected void |
unlock(StringTrie_2.Edge into,
boolean ownsParent,
Object cursor) |
doPut, findPrefixed, lock, newEdgeGreater, newEdgeLesser, onEmpty, returnValue, unlockprotected final StringTrie_2.Edge root
public void put(char[] key,
int start,
int end,
E value)
put in class StringTrie<E>public void put(String key, E value)
put in class StringTrie<E>protected void doPut(StringTrie_2.Edge into, char[] key, int index, int end, E value)
protected StringTrie_2.Edge newEdgeLesser(StringTrie_2.Edge previous, int keyMax, char[] existing, int matchesTo, char[] key, int keyIndex, int keyEnd, E value)
protected StringTrie_2.Edge newEdgeGreater(StringTrie_2.Edge previous, int keyMax, char[] existing, int matchesTo, char[] key, int keyIndex, int keyEnd, E value)
protected Object lock(StringTrie_2.Edge into, boolean ownsParent)
into - - The edge to lockownsParent - - Whether we already own an explicit lock on the parent.Object.wait(long, int); as you already own the lock.
long param is millis, should be zero.
int param is nanos, keep it in the hundreds.
DON'T DO ANYTHING WHICH COULD BLOCK FOR A LONG TIME.
Acquire locks tentatively, either with Lock.tryLock() for failfast,
or Lock.tryLock(long, java.util.concurrent.TimeUnit).
Wait times, if any, should be on a nano scale;
If ownsParent is false, you should be running in unsynchronized code.
The only use for synchronous method blocks in this case is to acquire a
Lock.
If ownsParent is true, you are safe from intrusion from above
(nobody will be able to modify your parent), but you still have
to contendprotected void unlock(StringTrie_2.Edge into, boolean ownsParent, Object cursor)
into - - The edge to lockownsParent - - If true, you are already synchronized on into.cursor - - Whatever object you returned when you locked.
This method is a stub for more sophisticated subclasses of StringTrie_2,
which may need to perform proper concurrent locking, or event dispatch.
It is called in the finally block of whatever code ran
lock(Edge, boolean).
If you use Edge into.wait(0, nanos) in lock(),
now would be a great time to call into into.notify() :)public String toString()
toString in class StringTrie<E>public E get(String key)
get in class StringTrie<E>public E get(char[] key)
get in class StringTrie<E>public E get(char[] key, int pos, int end)
get in class StringTrie<E>public E get(Chars keys, int pos, int end)
get in class StringTrie<E>protected E returnValue(StringTrie_2.Edge e, Chars keys, int pos, int end)
protected E onEmpty(StringTrie_2.Edge e, Chars keys, int pos, int end)
public void compress(CharPoolTrie charPoolTrie)
compress in class StringTrie<E>Copyright © December 07, 2012–2015 The Internet Party. All rights reserved.