|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.limegroup.gnutella.routing.HashFunction
The official platform-independent hashing function for query-routing. The key property is that it allows interpolation of hash tables of different sizes. More formally k*hash(x,n)<=hash(x, kn)<=k*hash(x,n)+1.
This experimental version does not necessarily work cross-platform, however, nor is it secure in any sense. See Chapter 12.3.2. of for details of multiplication-based algorithms.
Constructor Summary | |
HashFunction()
|
Method Summary | |
static java.lang.String[] |
getPrefixes(java.lang.String[] words)
|
static int |
hash(java.lang.String x,
byte bits)
|
static int |
hash(java.lang.String x,
int start,
int end,
byte bits)
Returns the same value as hash(x.substring(start, end), bits), but tries to avoid allocations. |
static int |
keywordEnd(java.lang.String query,
int i)
Returns the index just past the end of the keyword starting at the i'th position of query, or query.length() if no such index. |
static java.lang.String[] |
keywords(java.lang.String query)
Returns a list of canonicalized keywords in the given query, suitable for passing to hash(String,int). |
static int |
keywordStart(java.lang.String query,
int i)
Returns the index of the keyword starting at or after the i'th position of query, or -1 if no such luck. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public HashFunction()
Method Detail |
public static int hash(java.lang.String x, byte bits)
public static int hash(java.lang.String x, int start, int end, byte bits)
x
- the string to hashbits
- the number of bits to use in the resulting answerstart
- the start offset of the substring to hashend
- just PAST the end of the substring to hash
public static java.lang.String[] keywords(java.lang.String query)
public static int keywordStart(java.lang.String query, int i)
public static int keywordEnd(java.lang.String query, int i)
public static java.lang.String[] getPrefixes(java.lang.String[] words)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |