|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching • Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
IntSetSee also std/intsets This is different from the previous HashSet. First, in this you can only store integers. Second, it's similar to Java's When to use it? If you want to store a lot of integers in a set, and the set is dense, then it's a good choice. In this case, However, if your set is sparse and there's a huge distance between the elements (e.g. Its API is similar to the other set implementations. The following things are exported from this module: clear, union, missingOrExcl, isNil, incl, excl, items, ==, <=, =copy, toPackedSet, assign, PackedSet, symmetricDifference, contains, len, $, initPackedSet, <, *, -, excl, disjoint, difference, +, card, intersection, incl, containsOrIncl Example: import std/intsets var a: IntSet b = initIntSet() c = [8, 6, 3, 2, 1, 0].toIntSet() echo a # {} echo b # {} echo c # {8, 6, 3, 2, 1, 0} a.incl(2) a.incl(2) a.incl(5) a.incl(3) a.incl(3) echo a # {2, 5, 3} for n in a: # we can iterate over the elements echo n |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |