Set
implemented with a hash table.Keys of such a map cannot be null and require a working hash
method
core :: HashSet :: defaultinit
core :: Collection :: CONCURRENT
Type of the concurrent variant of this collectioncore :: HashCollection :: _array
core :: HashCollection :: _capacity
core :: HashCollection :: _first_item
core :: HashCollection :: _last_accessed_key
The last key accessed (used for cache)core :: HashCollection :: _last_accessed_node
The last node accessed (used for cache)core :: HashCollection :: _last_item
core :: HashCollection :: _the_length
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
core :: HashCollection :: array
core :: HashCollection :: array=
core :: HashCollection :: capacity
core :: HashCollection :: capacity=
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Collection :: combinations
Allr
-length combinations on self (in same order) without repeated elements.
core :: Collection :: combinations_with_replacement
Allr
-length combination on self (in same order) with repeated elements.
serialization :: Serializable :: core_serialize_to
Actual serialization ofself
to serializer
core :: Set :: defaultinit
core :: SimpleCollection :: defaultinit
core :: Cloneable :: defaultinit
core :: Object :: defaultinit
core :: Collection :: defaultinit
core :: HashCollection :: defaultinit
core :: HashSet :: defaultinit
core :: HashCollection :: first_item
core :: HashCollection :: first_item=
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
core :: HashCollection :: gt_collide
Count and update length of collisions fornode_at_idx
core :: Collection :: has_all
Does the collection contain at least each element ofother
?
core :: Collection :: has_any
Does the collection contain at least one element ofother
?
core :: Collection :: has_exactly
Does the collection contain exactly all the elements ofother
?
core :: Set :: intersection
Returns the intersection of this set with theother
set
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.
core :: HashCollection :: last_accessed_key
The last key accessed (used for cache)core :: HashCollection :: last_accessed_key=
The last key accessed (used for cache)core :: HashCollection :: last_accessed_node
The last node accessed (used for cache)core :: HashCollection :: last_accessed_node=
The last node accessed (used for cache)core :: HashCollection :: last_item
core :: HashCollection :: last_item=
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.core :: HashCollection :: node_at_idx
Return the node associated with the key (but with the index already known)core :: Object :: output_class_name
Display class name on stdout (debug only).core :: Collection :: permutations
Allr
-length permutations on self (all possible ordering) without repeated elements.
core :: Collection :: product
Cartesian product, overr
times self
.
core :: RemovableCollection :: remove
Remove an occurrence ofitem
core :: RemovableCollection :: remove_all
Remove all occurrences ofitem
core :: HashCollection :: remove_node
Remove the node assosiated with the keyserialization :: 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
)
core :: Collection :: serialize_to_pure_json
Utility to serialize a normal Json arraycore :: HashCollection :: st_collide
Count and update length of collisions forstore
core :: HashCollection :: the_length
core :: HashCollection :: the_length=
core :: Collection :: to_concurrent
Wrapsself
in a thread-safe collection
core :: Collection :: to_counter
Create and fill up a counter with the elements of `self.core :: Collection :: to_curlslist
Convert Collection[String] to CURLSListserialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
core :: Collection :: to_shuffle
Return a new array made of elements in a random order.Serializer::serialize
# A `Set` implemented with a hash table.
# Keys of such a map cannot be null and require a working `hash` method
class HashSet[E]
super Set[E]
super HashCollection[E]
redef type N: HashSetNode[E] is fixed
redef fun length do return _the_length
redef fun is_empty do return _the_length == 0
redef fun first
do
assert _the_length > 0
return _first_item._key
end
redef fun has(item)
do
return node_at(item) != null
end
redef fun add(item)
do
if _capacity == 0 then enlarge(17) # 17 because magic in `store`
var i = index_at(item)
var c = node_at_idx(i, item)
if c != null then
c._key = item
else
store(i,new HashSetNode[E](item))
end
end
redef fun remove(item) do remove_node(item)
redef fun clear do raz
redef fun iterator do return new HashSetIterator[E](self)
init
do
_capacity = 0
_the_length = 0
end
# Build a list filled with the items of `coll`.
init from(coll: Collection[E]) do
init
add_all(coll)
end
redef fun new_set do return new HashSet[E]
end
lib/core/collection/hash_collection.nit:424,1--478,3