Package net.sf.saxon.ma.map
Class ExtensibleMap
java.lang.Object
net.sf.saxon.ma.MapOrArray
net.sf.saxon.ma.map.MapItem
net.sf.saxon.ma.map.MapWithTypeCache
net.sf.saxon.ma.map.ExtensibleMap
- All Implemented Interfaces:
Iterable<KeyValuePair>,Callable,FunctionItem,GroundedValue,Item,Sequence
A general-purpose XDM map implementation that is ordered, that holds any kind of key,
and that supports incremental modification. Any duplicates added during map construction follow "use-last" semantics -
the new value replaces the old. This structure is therefore unsuited to cases where
duplicates need custom handling.
The implementation is similar to that of AbstractFixedMap, but the arrays of keys
and values are replaced by ZenoChains to allow functional modification,
and the map from atomic match keys to integer offsets is replaced by an immutable
map (currently from the VAVR library).
Because the integer offset of an entry within the ordered map is held in the index
structure and must therefore remain intact, the remove(AtomicValue) operation
does not physically remove entries, but instead adds them to a list of "logically removed"
entries.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.saxon.ma.map.MapItem
MapItem.KeyIterator -
Field Summary
Fields inherited from class net.sf.saxon.ma.map.MapWithTypeCache
knownKeyType, knownValueTypeFields inherited from class net.sf.saxon.ma.map.MapItem
mapConstructorDuplicatesAction, xslMapDuplicatesAction, xslRecordDuplicatesAction -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ExtensibleMapConstruct anExtensibleMapfrom the contents of an existing mapget(AtomicValue key) Get an entry from the Mapstatic intgetOffset(ImmutableHashTrieMap<AtomicMatchKey, Integer> index, AtomicMatchKey key) Get the offset of an entry in the map (that is, its 0-based position in the map orderingiterator()Return an iterator of key-value pairs.Get the content as an iterable collection of key value pairsput(AtomicValue key, GroundedValue value) Create a new map containing the existing entries in the map plus an additional entry, without modifying the original.remove(AtomicValue key) Remove an entry from the mapintsize()Get the size of the mapMethods inherited from class net.sf.saxon.ma.map.MapWithTypeCache
conforms, setKnownTypeMethods inherited from class net.sf.saxon.ma.map.MapItem
atomize, call, deepEqual40, deepEquals, effectiveBooleanValue, entries, export, followingKeyValuePairs, getAnnotations, getArity, getDescription, getFunctionItemType, getFunctionName, getGenre, getItemType, getItemTypeOfSequence, getOperandRoles, getSpecVersion, getTypedValue, getU, getUnicodeStringValue, getWithPlan, isArray, isEmpty, isKnownToConform, isMap, isTrustedResultType, itemAt, keys, makeNewContext, mapToString, precedingKeyValuePairs, setSpecVersion, toShortStringMethods inherited from class net.sf.saxon.ma.MapOrArray
obtainRootJNodeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sf.saxon.om.FunctionItem
isSequenceVariadicMethods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materializeMethods inherited from interface net.sf.saxon.om.Item
getLabel, getLength, getStringValue, head, isStreamed, iterate, reduce, subsequenceMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Constructor Details
-
ExtensibleMap
public ExtensibleMap(int specVersion)
-
-
Method Details
-
copyOf
Construct anExtensibleMapfrom the contents of an existing map- Parameters:
map- an existing map
-
get
Get an entry from the Map -
size
public int size()Get the size of the map -
keyValuePairs
Get the content as an iterable collection of key value pairs- Specified by:
keyValuePairsin classMapItem- Returns:
- an iterable collection of key value pairs
-
iterator
Return an iterator of key-value pairs.- Specified by:
iteratorin interfaceIterable<KeyValuePair>- Returns:
- an Iterator of key-value pairs.
-
put
Create a new map containing the existing entries in the map plus an additional entry, without modifying the original. If there is already an entry with the specified key, this entry is replaced by the new entry. -
remove
Remove an entry from the map -
getOffset
Get the offset of an entry in the map (that is, its 0-based position in the map ordering- Parameters:
key- the required key- Returns:
- the 0-based position of the relevant entry in the map, or -1 if the key is not present
-