Package net.sf.saxon.ma.map
Class ShapedMap
java.lang.Object
net.sf.saxon.ma.MapOrArray
net.sf.saxon.ma.map.MapItem
net.sf.saxon.ma.map.ShapedMap
- All Implemented Interfaces:
Callable,FunctionItem,GroundedValue,Item,Sequence
- Direct Known Subclasses:
SparseShapedMap
A
ShapedMap is an implementation of XDM maps optimised for the case
where many maps have the same set of string-valued keys.
It has the additional property that the keys() method delivers the keys in a consistent order.
The class implements the method getWithPlan(AtomicValue, Stack) so that a
lookup expression such as $record?field using a statically-known lookup
key is able to use the slot number established on a previous call of the same
expression, avoiding the cost of a hash lookup.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class net.sf.saxon.ma.map.MapItem
MapItem.KeyIterator -
Field Summary
FieldsFields inherited from class net.sf.saxon.ma.map.MapItem
mapConstructorDuplicatesAction, xslMapDuplicatesAction, xslRecordDuplicatesAction -
Constructor Summary
ConstructorsConstructorDescriptionShapedMap(Shape shape, GroundedValue... values) Create an instance of aShapedMapwhose structure is defined by the suppliedShape -
Method Summary
Modifier and TypeMethodDescriptionbooleanAsk whether a given string is present as a key in the mapGet an entry from the map, supplying a Java String as the keyget(AtomicValue key) Get an entry from the MapgetByPosition(int slot) Get a value by its zero-based positionGet the type of the map.getU(UnicodeString key) Get an entry from the map, supplying aUnicodeStringas the keygetWithPlan(AtomicValue key, Stack<LookupPlan> plans) Get an entry from the Map, supplying an execution plan which the callee can add information to.voidinitialPut(int slot, GroundedValue value) keys()Get the set of all key values in the map.Get the set of all key-value pairs in the mapput(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.MapItem
atomize, call, conforms, deepEqual40, deepEquals, effectiveBooleanValue, entries, export, followingKeyValuePairs, getAnnotations, getArity, getDescription, getFunctionItemType, getFunctionName, getGenre, getItemTypeOfSequence, getOperandRoles, getSpecVersion, getTypedValue, getUnicodeStringValue, isArray, isEmpty, isKnownToConform, isMap, isTrustedResultType, itemAt, 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 net.sf.saxon.om.Sequence
makeRepeatable
-
Field Details
-
values
-
shape
-
-
Constructor Details
-
Method Details
-
initialPut
-
get
Get an entry from the Map -
getByPosition
Get a value by its zero-based position -
getWithPlan
Get an entry from the Map, supplying an execution plan which the callee can add information to.- Overrides:
getWithPlanin classMapItem- Parameters:
key- the value of the keyplans- a list of suggested lookup plans; the callee is free to use these or ignore them as it wishes, and can also add new plans for use on future evaluation of the same expression. The plan is specific to a particular key value: in practice, the method is only used when the lookup key is known statically.- Returns:
- the value associated with the given key, or null if the key is not present in the map.
-
get
Get an entry from the map, supplying a Java String as the key- Parameters:
key- the key- Returns:
- the relevant entry if present, or null if absent.
-
getU
Get an entry from the map, supplying aUnicodeStringas the key -
contains
Ask whether a given string is present as a key in the map- Parameters:
key- the key being tested- Returns:
- true if the key is present
-
size
public int size()Get the size of the map -
keys
Get the set of all key values in the map. -
keyValuePairs
Get the set of all key-value pairs in the map- Specified by:
keyValuePairsin classMapItem- Returns:
- an iterable containing all the 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 -
getItemType
Get the type of the map. This method is used largely for diagnostics, to report the type of a map when it differs from the required type.- Overrides:
getItemTypein classMapItem- Parameters:
th- the type hierarchy cache- Returns:
- the type of this map
-