Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

Programming 1 (BI)
  ▸ exercises
  ▸ quick link

teaching assets


Félévek

* 2025/26/2
* archívum


Linkek

* kalendárium
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C#
* D lang.
* Java
* Nim
* Nim2
  + exercises
* XC=BASIC
* old
  ✦C++, ✦Clojure, ✦Scala


[ edit | logout ]
[ sandbox | passwd ]

IntSet

See 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 BitSet.

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, intsets is very fast and efficient.

However, if your set is sparse and there's a huge distance between the elements (e.g. {1, 750_000, 2_000_000}), then a HashSet[int] is a better choice.

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
Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2026 June 03, 10:43