Package org.apache.solr.common.util
Class SimpleOrderedMap<T>
java.lang.Object
org.apache.solr.common.util.NamedList<T>
org.apache.solr.common.util.SimpleOrderedMap<T>
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Map.Entry<String,,T>> Map<String,,T> MapSerializable,MapWriter,NavigableObject,org.noggit.JSONWriter.Writable
SimpleOrderedMap is a NamedList where access by key is more important than
maintaining order when it comes to representing the held data in other forms, as ResponseWriters
normally do. It's normally not a good idea to repeat keys or use null keys, but this is not
enforced. If key uniqueness enforcement is desired, use a regular Map.
For example, a JSON response writer may choose to write a SimpleOrderedMap as {"foo":10,"bar":20} and may choose to write a NamedList as ["foo",10,"bar",20]. An XML response writer may choose to render both the same way.
This class does not provide efficient lookup by key. The lookup performance is only O(N), and not O(1) or O(Log N) as it is for the most common Map-implementations. Its main purpose is to hold data to be serialized. It aims to minimize overhead and to be efficient at adding new elements.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.solr.common.util.NamedList
NamedList.NamedListEntry<T>Nested classes/interfaces inherited from interface org.apache.solr.common.MapWriter
MapWriter.EntryWriter -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty instanceSimpleOrderedMap(int sz) SimpleOrderedMap(Map.Entry<String, T>[] nameValuePairs) SimpleOrderedMap(MapWriter mapWriter) Can convert aSolrParamsand other things. -
Method Summary
Modifier and TypeMethodDescriptionclone()Makes a shallow copy of the named list.booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleaninthashCode()booleanisEmpty()keySet()static SimpleOrderedMap<Object> of()Returns a shared, empty, and immutable instance ofSimpleOrderedMap.static <T> SimpleOrderedMap<T> Returns an immutable instance ofSimpleOrderedMapwith a single key-value pair.voidvalues()Methods inherited from class org.apache.solr.common.util.NamedList
add, addAll, addAll, asMap, asShallowMap, asShallowMap, clear, forEach, get, get, getAll, getBooleanArg, getImmutableCopy, getName, getOrDefault, getVal, indexOf, indexOf, iterator, remove, remove, removeAll, removeBooleanArg, removeConfigArgs, setName, setVal, size, toSolrParams, toString, writeMapMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll, sizeMethods inherited from interface org.apache.solr.common.NavigableObject
_forEachEntry, _forEachEntry, _forEachEntry, _get, _get, _getStr, _getStr, _size
-
Constructor Details
-
SimpleOrderedMap
public SimpleOrderedMap()Creates an empty instance -
SimpleOrderedMap
public SimpleOrderedMap(int sz) -
SimpleOrderedMap
-
SimpleOrderedMap
Can convert aSolrParamsand other things.
-
-
Method Details
-
clone
Description copied from class:NamedListMakes a shallow copy of the named list. -
equals
-
hashCode
public int hashCode() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<String,T>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,T>
-
get
Has linear lookup time O(N)
-
put
-
remove
-
putAll
-
keySet
-
values
-
entrySet
-
of
Returns an immutable instance ofSimpleOrderedMapwith a single key-value pair.- Returns:
SimpleOrderedMapcontaining one key-value pair
-
of
Returns a shared, empty, and immutable instance ofSimpleOrderedMap.- Returns:
- Empty
SimpleOrderedMap(immutable)
-