UnrolledList
Stores the elements in the items
array. The elements in the items
array
begin at head_index
and end right before tail_index
. The data is contiguous,
but there can be empty cells at the beginning and the end of the array.
more_collections :: UnrolledNode :: _head_index
Index of the first element initems
more_collections :: UnrolledNode :: _items
Array
of items in this node, filled with null
more_collections :: UnrolledNode :: _tail_index
Index after the last element initems
more_collections :: UnrolledNode :: capacity=
Desired length ofitems
more_collections :: UnrolledNode :: full
more_collections :: UnrolledNode :: head_index
Index of the first element initems
more_collections :: UnrolledNode :: head_index=
Index of the first element initems
more_collections :: UnrolledNode :: items
Array
of items in this node, filled with null
more_collections :: UnrolledNode :: items=
Array
of items in this node, filled with null
more_collections :: UnrolledNode :: move_head
Move towards the tail all elements at and afterindex
of displace
cells
more_collections :: UnrolledNode :: move_tail
Move towards the head all elements beforeindex
of displace
cells
more_collections :: UnrolledNode :: next
more_collections :: UnrolledNode :: prev
more_collections :: UnrolledNode :: tail_index
Index after the last element initems
more_collections :: UnrolledNode :: tail_index=
Index after the last element initems
more_collections $ UnrolledNode :: SELF
Type of this instance, automatically specialized in every classmore_collections $ UnrolledNode :: core_serialize_to
Actual serialization ofself
to serializer
more_collections $ UnrolledNode :: from_deserializer
Create an instance of this class from thedeserializer
more_collections :: UnrolledNode :: _head_index
Index of the first element initems
more_collections :: UnrolledNode :: _items
Array
of items in this node, filled with null
more_collections :: UnrolledNode :: _tail_index
Index after the last element initems
serialization :: Serializable :: accept_inspect_serializer_core
serialization :: Serializable :: accept_json_serializer
Refinable service to customize the serialization of this class to JSONserialization :: Serializable :: accept_msgpack_attribute_counter
Hook to customize the behavior of theAttributeCounter
serialization :: Serializable :: accept_msgpack_serializer
Hook to customize the serialization of this class to MessagePackserialization :: Serializable :: add_to_bundle
Called by[]=
to dynamically choose the appropriate method according
more_collections :: UnrolledNode :: capacity=
Desired length ofitems
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
serialization :: Serializable :: core_serialize_to
Actual serialization ofself
to serializer
core :: Object :: defaultinit
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
more_collections :: UnrolledNode :: full
more_collections :: UnrolledNode :: head_index
Index of the first element initems
more_collections :: UnrolledNode :: head_index=
Index of the first element initems
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
more_collections :: UnrolledNode :: items
Array
of items in this node, filled with null
more_collections :: UnrolledNode :: items=
Array
of items in this node, filled with null
more_collections :: UnrolledNode :: move_head
Move towards the tail all elements at and afterindex
of displace
cells
more_collections :: UnrolledNode :: move_tail
Move towards the head all elements beforeindex
of displace
cells
serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: Object :: native_class_name
The class name of the object in CString format.more_collections :: UnrolledNode :: next
core :: Object :: output_class_name
Display class name on stdout (debug only).more_collections :: UnrolledNode :: prev
serialization :: Serializable :: serialize_msgpack
Serializeself
to MessagePack bytes
serialization :: Serializable :: serialize_to
Serializeself
to serializer
serialization :: Serializable :: serialize_to_json
Serializeself
to JSON
serialization :: Serializable :: serialize_to_or_delay
Accept references or force direct serialization (usingserialize_to
)
more_collections :: UnrolledNode :: tail_index
Index after the last element initems
more_collections :: UnrolledNode :: tail_index=
Index after the last element initems
serialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
Serializer::serialize
# Node composing an `UnrolledList`
#
# Stores the elements in the `items` array. The elements in the `items` array
# begin at `head_index` and end right before `tail_index`. The data is contiguous,
# but there can be empty cells at the beginning and the end of the array.
private class UnrolledNode[E]
var prev: nullable UnrolledNode[E] = null
var next: nullable UnrolledNode[E] = null
# Desired length of `items`
var capacity: Int
# `Array` of items in this node, filled with `null`
var items = new Array[nullable E].filled_with(null, capacity) is lazy
# Index of the first element in `items`
var head_index = 0
# Index after the last element in `items`
var tail_index = 0
fun length: Int do return tail_index - head_index
fun full: Bool do return length == capacity
fun is_empty: Bool do return tail_index == head_index
# Move towards the head all elements before `index` of `displace` cells
fun move_tail(index, displace: Int)
do
for i in [tail_index-1..head_index+index].step(-1) do
items[i+displace] = items[i]
end
end
# Move towards the tail all elements at and after `index` of `displace` cells
fun move_head(index, displace: Int)
do
for i in [head_index..head_index+index[ do
items[i-displace] = items[i]
end
end
end
lib/more_collections/more_collections.nit:605,1--649,3