core :: ArraySet :: defaultinit
core :: ArraySet :: with_capacity
Create an empty set with a given capacity.core $ ArraySet :: remove_all
Remove all occurrences ofitem
core :: Collection :: CONCURRENT
Type of the concurrent variant of this collectionserialization :: 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 :: 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 :: ArraySet :: defaultinit
core :: SimpleCollection :: defaultinit
core :: Object :: defaultinit
core :: Cloneable :: defaultinit
core :: Collection :: defaultinit
core :: Set :: defaultinit
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
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.
serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: 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
serialization :: Serializable :: serialize_msgpack
Serializeself
to MessagePack bytes
serialization :: Serializable :: serialize_to
Serializeself
to serializer
serialization :: Serializable :: serialize_to_json
Serializeself
to JSON
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.core :: ArraySet :: with_capacity
Create an empty set with a given capacity.Serializer::serialize
# A set implemented with an Array.
class ArraySet[E]
super Set[E]
# The stored elements.
private var array: Array[E] is noinit
redef fun has(e) do return _array.has(e)
redef fun add(e) do if not _array.has(e) then _array.add(e)
redef fun is_empty do return _array.is_empty
redef fun length do return _array.length
redef fun first
do
assert _array.length > 0
return _array.first
end
redef fun remove(item)
do
var i = _array.index_of(item)
if i >= 0 then remove_at(i)
end
redef fun remove_all(item) do remove(item)
redef fun clear do _array.clear
redef fun iterator do return new ArraySetIterator[E](_array.iterator)
# Assume the capacity is at least `cap`.
fun enlarge(cap: Int) do _array.enlarge(cap)
private fun remove_at(i: Int)
do
_array[i] = _array.last
_array.pop
end
# Create an empty set
init do _array = new Array[E]
# Create an empty set with a given capacity.
init with_capacity(i: Int) do _array = new Array[E].with_capacity(i)
redef fun new_set do return new ArraySet[E]
# Shallow clone of `self`
#
# ~~~
# var a = new ArraySet[Int]
# a.add 1
# a.add 2
# var b = a.clone
# assert a == b
# a.add 3
# assert a != b
# b.add 3
# assert a == b
# ~~~
#
# Note that the clone is shallow and keys and values are shared between `self` and the result.
#
# ~~~
# var aa = new ArraySet[Array[Int]]
# aa.add([1,2])
# var bb = aa.clone
# assert aa == bb
# aa.first.add 5
# assert aa == bb
# ~~~
redef fun clone
do
var res = new ArraySet[E]
res.add_all self
return res
end
end
lib/core/collection/array.nit:593,1--673,3