struct Set(T)
Overview
Set
implements a collection of unordered values with no duplicates.
An Enumerable
object can be converted to Set
using the #to_set
method.
Set
uses Hash
as storage, so you must note the following points:
- Equality of elements is determined according to
Object#==
andObject#hash
. Set
assumes that the identity of each element does not change while it is stored. Modifying an element of a set will render the set to an unreliable state.
Example
s1 = Set{1, 2}
s2 = [1, 2].to_set
s3 = Set.new [1, 2]
s1 == s2 # => true
s1 == s3 # => true
s1.add(2)
s1.concat([6, 8])
s1.subset_of? s2 # => false
s2.subset_of? s1 # => true
Included Modules
- Enumerable(T)
- Iterable(T)
Defined in:
ssz/codec.crClass Method Summary
Instance methods inherited from module Enumerable(T)
hash_tree_root : Bytes
hash_tree_root,
ssz_basic? : Bool
ssz_basic?,
ssz_encode(io : IO)
ssz_encode,
ssz_size : Int32
ssz_size,
ssz_variable? : Bool
ssz_variable?
Class methods inherited from module Enumerable(T)
ssz_basic? : Bool
ssz_basic?
Instance methods inherited from class Object
ssz_basic? : Bool
ssz_basic?,
ssz_encode(io : IO)ssz_encode : Bytes ssz_encode, ssz_fixed? : Bool ssz_fixed?, ssz_size : Int32 ssz_size, ssz_variable? : Bool ssz_variable?
Class methods inherited from class Object
ssz_basic? : Bool
ssz_basic?,
ssz_decode(io : IO, size : Int32 = 0)ssz_decode(bytes : Bytes) ssz_decode, ssz_fixed? : Bool ssz_fixed?, ssz_variable? : Bool ssz_variable?