rio-0.1.14.0: A standard library for Haskell

Safe HaskellSafe
LanguageHaskell2010

RIO.Set.Partial

Contents

Description

Set partial functions. Import as:

import qualified RIO.Set.Partial as Set'
Synopsis

Indexed

findIndex :: Ord a => a -> Set a -> Int #

O(log n). Return the index of an element, which is its zero-based index in the sorted sequence of elements. The index is a number from 0 up to, but not including, the size of the set. Calls error when the element is not a member of the set.

findIndex 2 (fromList [5,3])    Error: element is not in the set
findIndex 3 (fromList [5,3]) == 0
findIndex 5 (fromList [5,3]) == 1
findIndex 6 (fromList [5,3])    Error: element is not in the set

Since: containers-0.5.4

elemAt :: Int -> Set a -> a #

O(log n). Retrieve an element by its index, i.e. by its zero-based index in the sorted sequence of elements. If the index is out of range (less than zero, greater or equal to size of the set), error is called.

elemAt 0 (fromList [5,3]) == 3
elemAt 1 (fromList [5,3]) == 5
elemAt 2 (fromList [5,3])    Error: index out of range

Since: containers-0.5.4

deleteAt :: Int -> Set a -> Set a #

O(log n). Delete the element at index, i.e. by its zero-based index in the sorted sequence of elements. If the index is out of range (less than zero, greater or equal to size of the set), error is called.

deleteAt 0    (fromList [5,3]) == singleton 5
deleteAt 1    (fromList [5,3]) == singleton 3
deleteAt 2    (fromList [5,3])    Error: index out of range
deleteAt (-1) (fromList [5,3])    Error: index out of range

Since: containers-0.5.4

Min/Max

findMin :: Set a -> a #

O(log n). The minimal element of a set.

findMax :: Set a -> a #

O(log n). The maximal element of a set.

deleteFindMin :: Set a -> (a, Set a) #

O(log n). Delete and find the minimal element.

deleteFindMin set = (findMin set, deleteMin set)

deleteFindMax :: Set a -> (a, Set a) #

O(log n). Delete and find the maximal element.

deleteFindMax set = (findMax set, deleteMax set)