Top Description Inners Fields Constructors Methods
io.undertow.util

public Class SubstringMap<V>

extends Object
Class Inheritance
Static Imports
org.wildfly.common.Assert.checkNotNullParamWithNullPointerException

A string keyed map that can be accessed as a substring, eliminating the need to allocate a new string to do a key comparison against.

This class uses linear probing and is thread safe due to copy on write semantics. As such it is not recomended for data that changes frequently.

This class does not actually implement the map interface to avoid implementing unnecessary operations.

Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private static final int
private int
private volatile Object[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public synchronized void
private boolean
doEquals(String s1, String s2, int length)

private void
doPut(Object[] newTable, String key, Object value)

public SubstringMap.SubstringMatch<V>
get(String key, int length)

public SubstringMap.SubstringMatch<V>
get(String key)

private SubstringMap.SubstringMatch<V>
get(String key, int length, boolean exact)

private static int
hash(String value, int length)

public Iterable<String>
keys()

public synchronized void
put(String key, V value)

public synchronized V
private int
tablePos(Object[] table, int hash)

public Map<String, V>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALL_BUT_LAST_BITback to summary
private static final int ALL_BUT_LAST_BIT
sizeback to summary
private int size
tableback to summary
private volatile Object[] table

Constructor Detail

SubstringMapback to summary
public SubstringMap()

Method Detail

clearback to summary
public synchronized void clear()
doEqualsback to summary
private boolean doEquals(String s1, String s2, int length)
doPutback to summary
private void doPut(Object[] newTable, String key, Object value)
getback to summary
public SubstringMap.SubstringMatch<V> get(String key, int length)
getback to summary
public SubstringMap.SubstringMatch<V> get(String key)
getback to summary
private SubstringMap.SubstringMatch<V> get(String key, int length, boolean exact)
hashback to summary
private static int hash(String value, int length)
keysback to summary
public Iterable<String> keys()
putback to summary
public synchronized void put(String key, V value)
removeback to summary
public synchronized V remove(String key)
tablePosback to summary
private int tablePos(Object[] table, int hash)
toMapback to summary
public Map<String, V> toMap()
io.undertow.util back to summary

public final Class SubstringMap.SubstringMatch<V>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final String
private final V

Constructor Summary

AccessConstructor and Description
public
SubstringMatch(String key, V value)

Method Summary

Modifier and TypeMethod and Description
public String
public V
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keyback to summary
private final String key
valueback to summary
private final V value

Constructor Detail

SubstringMatchback to summary
public SubstringMatch(String key, V value)

Method Detail

getKeyback to summary
public String getKey()
getValueback to summary
public V getValue()