Package org.apache.sis.io.wkt
Class StoredTree.Deflater
java.lang.Object
org.apache.sis.io.wkt.StoredTree.Deflater
- Enclosing class:
- StoredTree
A helper class for compressing a tree of
Elements as a tree of StoredTree.Nodes.
Contrarily to Element instances, Nodes instances can be shared between many trees.
Each instances shall be used for constructing only one StoredTree.Node. After node construction, this
instance lives longer in the sharedValues map for sharing offsets arrays.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intNumber of valid elements inoffsets.private short[]TheElement.offsetvalue ofStoredTree.roottogether with offsets of allElement.childrenin iteration order.Pool to use for sharing unique instances of values. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final voidAdds the givenElement.offsetvalue.booleanCompares theoffsetsarrays for equality.inthashCode()Computes a hash code value based only on theoffsetsarray.(package private) final short[]offsets()Returns allElement.offsetvalues in iteration order.(package private) final ObjectReturns a unique instance of given object.
-
Field Details
-
offsets
private short[] offsetsTheElement.offsetvalue ofStoredTree.roottogether with offsets of allElement.childrenin iteration order. Order is defined byStoredTree.Nodeconstructor. This array is expanded as needed. Shall not be modified after call tooffsets(). -
count
private int countNumber of valid elements inoffsets.
-
Constructor Details
-
Deflater
Pool of previously constructed values used for replacing equal instances by unique instances. May containString,Long,DoubleandStoredTree.Nodeinstances among others.- Parameters:
sharedValues- pool of previously created objects.
-
-
Method Details
-
unique
Returns a unique instance of given object. The given value can be aStoredTree.Nodeinstance provided that it is not an anonymous node (i.e.StoredTree.keyword()shall be non-null).- Parameters:
value- the value for which to get a unique instance.- Returns:
- a previous instance from the pool, or
valueif none. - See Also:
-
addOffset
Adds the givenElement.offsetvalue.- See Also:
-
offsets
final short[] offsets()Returns allElement.offsetvalues in iteration order. This method may return an array shared by differentStoredTree.Nodeinstances; do not modify. -
equals
-
hashCode
public int hashCode()Computes a hash code value based only on theoffsetsarray. Seeequals(Object)for rational.
-