Class FixedMap
- All Implemented Interfaces:
Iterable<KeyValuePair>,Callable,FunctionItem,GroundedValue,Item,Sequence
The implementation is based on an array of keys, an array of corresponding values,
and a mutable Java java.util.HashMap (but encapsulated
so no mutation can take place after the map has been built) that maps atomic match keys
to integer positions in the array. If put or remove operations
are subsequently attempted, the map is copied to a different implementation structure
that supports functional modification.
The underlying implementation uses an instance of HashMap<AtomicMatchKey, KeyValuePair>
For many data types this means that the key is held twice, once as the key, and once as part
of the value. The reason for this is that the keys() function needs to return
the original keys as supplied, complete with type annotation, which would not (always) have
the same equality semantics. The AtomicMatchKey is computed from the actual key
and in some cases is simply a wrapper with a different equals() method.
-
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.AbstractFixedMap
index, valuesFields 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
ConstructorsModifierConstructorDescriptionprotectedFixedMap(AtomicValue[] keys, GroundedValue[] values, HashMap<AtomicMatchKey, Integer> index, int specVersion) Construct aFixedMapsupplying the entries as an array of keys and a corresponding array of value. -
Method Summary
Modifier and TypeMethodDescriptionprotected AtomicValuegetKey(int position) Get the key at a given offset.Methods inherited from class net.sf.saxon.ma.map.AbstractFixedMap
ensureIndexed, get, getBuilder, getOffset, getPosition, getValue, iterator, keyValuePairs, put, putOffsetIfAbsent, remove, size, toStringMethods 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, 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
-
FixedMap
protected FixedMap(AtomicValue[] keys, GroundedValue[] values, HashMap<AtomicMatchKey, Integer> index, int specVersion) Construct aFixedMapsupplying the entries as an array of keys and a corresponding array of value. The caller is responsible for ensuring that there are no duplicate keys. The two arrays (of keys and values) must have the same length. The content of the arrays must not be subsequently modified.- Parameters:
keys- an array of keysvalues- a corresponding array of valuesindex- a hash map indexing the values
-
-
Method Details
-
getKey
Description copied from class:AbstractFixedMapGet the key at a given offset. This method is provided for use by subclasses, which can store the actual key in different ways.- Specified by:
getKeyin classAbstractFixedMap- Parameters:
position- the offset (sibling position within the ordered map) of the required key- Returns:
- the key at the specified position
-