Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Dense int set or a 64-ary tree that covers [0, n)
.
https://github.com/maspypy/library/blob/main/ds/fastset.hpp
FIXME: too slow compared to the original implementation.
Synopsis
- wordDIS :: Int
- data DenseIntSet s = DenseIntSet {}
- newDIS :: PrimMonad m => Int -> m (DenseIntSet (PrimState m))
- validateKeyDIS :: HasCallStack => String -> DenseIntSet s -> Int -> ()
- sizeDIS :: PrimMonad m => DenseIntSet (PrimState m) -> m Int
- memberDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m Bool
- notMemberDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m Bool
- insertDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m ()
- deleteDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m ()
- lookupGEDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m (Maybe Int)
- findGEDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m Int
- lookupGTDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m (Maybe Int)
- findGTDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m Int
- lookupLEDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m (Maybe Int)
- findLEDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m Int
- lookupLTDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m (Maybe Int)
- findLTDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m Int
- lookupMinDIS :: PrimMonad m => DenseIntSet (PrimState m) -> m (Maybe Int)
- findMinDIS :: (HasCallStack, PrimMonad m) => DenseIntSet (PrimState m) -> m Int
- deleteFindMinMayDIS :: PrimMonad m => DenseIntSet (PrimState m) -> m (Maybe Int)
- deleteFindMinDIS :: (HasCallStack, PrimMonad m) => DenseIntSet (PrimState m) -> m Int
- lookupMaxDIS :: PrimMonad m => DenseIntSet (PrimState m) -> m (Maybe Int)
- findMaxDIS :: (HasCallStack, PrimMonad m) => DenseIntSet (PrimState m) -> m Int
- deleteFindMaxMayDIS :: PrimMonad m => DenseIntSet (PrimState m) -> m (Maybe Int)
- deleteFindMaxDIS :: (HasCallStack, PrimMonad m) => DenseIntSet (PrimState m) -> m Int
- unsafeKeysDIS :: PrimMonad m => DenseIntSet (PrimState m) -> m (Vector Int)
Documentation
data DenseIntSet s #
Dense int set or a 64-ary tree that covers [0, n)
.
= (Internal) segments
The idea is very similar to hibitset, with top and bottom reversed.
[.][.][.][.][.][.][.][.] .. Layer 0: dense bits [..........][..........] .. Layer 1: sparse (1/64) [......................] .. Layer 2: more sparse (1/64^2)
newDIS :: PrimMonad m => Int -> m (DenseIntSet (PrimState m)) #
\(O(N \log N)\) Creates a new DenseIntSet
that covers [0, n)
.
validateKeyDIS :: HasCallStack => String -> DenseIntSet s -> Int -> () #
(Internal) Keys out of the range are reported as runtime error.
sizeDIS :: PrimMonad m => DenseIntSet (PrimState m) -> m Int #
\(O(1)\) Returns the number of elements in the set.
memberDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m Bool #
\(O(\log N)\) Tests if k
is in the set.
notMemberDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m Bool #
\(O(\log N)\) Tests if k
is not in the set.
insertDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m () #
\(O(\log N)\) Inserts k
to the set.
deleteDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m () #
\(O(\log N)\) Deletes k
from the set.
GT / GE
lookupGEDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m (Maybe Int) #
\(O(\log N)\) Finds the smallest k'
s.t. k' >= k
in the set.
lookupGTDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m (Maybe Int) #
\(O(\log N)\)
LT / LE
lookupLEDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m (Maybe Int) #
\(O(\log N)\) Finds the biggest k'
s.t. k' <= k
in the set.
lookupLTDIS :: PrimMonad m => DenseIntSet (PrimState m) -> Int -> m (Maybe Int) #
\(O(\log N)\)
Min / Max
lookupMinDIS :: PrimMonad m => DenseIntSet (PrimState m) -> m (Maybe Int) #
\(O(\log N)\) Not tested.
findMinDIS :: (HasCallStack, PrimMonad m) => DenseIntSet (PrimState m) -> m Int #
\(O(\log N)\) Not tested.
deleteFindMinMayDIS :: PrimMonad m => DenseIntSet (PrimState m) -> m (Maybe Int) #
\(O(\log N)\) Not tested.
deleteFindMinDIS :: (HasCallStack, PrimMonad m) => DenseIntSet (PrimState m) -> m Int #
\(O(\log N)\) Not tested.
lookupMaxDIS :: PrimMonad m => DenseIntSet (PrimState m) -> m (Maybe Int) #
\(O(\log N)\) Not tested.
findMaxDIS :: (HasCallStack, PrimMonad m) => DenseIntSet (PrimState m) -> m Int #
\(O(\log N)\) Not tested.
deleteFindMaxMayDIS :: PrimMonad m => DenseIntSet (PrimState m) -> m (Maybe Int) #
\(O(\log N)\) Not tested.
deleteFindMaxDIS :: (HasCallStack, PrimMonad m) => DenseIntSet (PrimState m) -> m Int #
\(O(\log N)\) Not tested.
unsafeKeysDIS :: PrimMonad m => DenseIntSet (PrimState m) -> m (Vector Int) #
\(O(N)\) Not tested.