sdp-0.2: Simple Data Processing
Copyright(c) Andrey Mulik 2019
LicenseBSD-style
Maintainerwork.a.mulik@gmail.com
Portabilitynon-portable (GHC Extensions)
Safe HaskellTrustworthy
LanguageHaskell2010

SDP.Set

Contents

Description

SDP.Set provides Set - class for basic set operations.

Synopsis

SetWith

class Nullable s => SetWith s o | s -> o where Source #

SetWith is a class of data structures, that can represent sets.

SetWith doesn't provide data protection/validation before each first action. All functions (except setWith) works correctly only with correct sets. SetWith guarantee only that the returned data is correct. So if you need maximum reliability and security, use containers. But if you want simplicity, openness and a lot of non-set functions without extra conversions, then you are at the right place.

Note that function of type Compare o must follow total order laws (antisymmetry, transitivity and connexity). If you use the wrong comparator, the result may become implementation-dependent.

Methods

setWith :: Compare o -> s -> s Source #

Creates ordered set from linear structure.

default setWith :: Linear s o => Compare o -> s -> s Source #

groupSetWith :: Compare o -> (o -> o -> o) -> s -> s Source #

Creates set from linear structure using additional function for choice/merge equal elements.

default groupSetWith :: Linear s o => Compare o -> (o -> o -> o) -> s -> s Source #

insertWith :: Compare o -> o -> s -> s Source #

Adding element to set.

default insertWith :: Linear s o => Compare o -> o -> s -> s Source #

deleteWith :: Compare o -> o -> s -> s Source #

Deleting element from set.

default deleteWith :: Linear s o => Compare o -> o -> s -> s Source #

intersectionWith :: Compare o -> s -> s -> s Source #

Intersection of two sets.

differenceWith :: Compare o -> s -> s -> s Source #

Difference (relative complement, aka A / B) of two sets.

symdiffWith :: Compare o -> s -> s -> s Source #

Symmetric difference of two sets.

unionWith :: Compare o -> s -> s -> s Source #

Union of two sets.

intersectionsWith :: Foldable f => Compare o -> f s -> s Source #

differencesWith :: Foldable f => Compare o -> f s -> s Source #

unionsWith :: Foldable f => Compare o -> f s -> s Source #

Fold by unionWith.

symdiffsWith :: Foldable f => Compare o -> f s -> s Source #

Fold by symdiffWith.

isIntersectsWith :: Compare o -> s -> s -> Bool Source #

Compares sets on intersection.

isDisjointWith :: Compare o -> s -> s -> Bool Source #

Compares sets on disjoint.

memberWith :: Compare o -> o -> s -> Bool Source #

Same as elem, but can work faster. By default, uses find.

default memberWith :: (t o ~~ s, Foldable t) => Compare o -> o -> s -> Bool Source #

isSubsetWith :: Compare o -> s -> s -> Bool Source #

Сhecks whether a first set is a subset of second.

default isSubsetWith :: (t o ~~ s, Foldable t) => Compare o -> s -> s -> Bool Source #

subsets :: Ord o => s -> [s] Source #

Generates a list of different subsets (including empty and equivalent).

default subsets :: (Linear s o, Ord o) => s -> [s] Source #

lookupLTWith :: Compare o -> o -> s -> Maybe o Source #

lookupLTWith trying to find lesser element in set.

lookupGTWith :: Compare o -> o -> s -> Maybe o Source #

lookupGTWith trying to find greater element in set.

lookupGEWith :: Compare o -> o -> s -> Maybe o Source #

lookupGEWith trying to find greater or equal element in set.

lookupLEWith :: Compare o -> o -> s -> Maybe o Source #

lookupLEWith trying to find lesser or equal element in set.

Instances

Instances details
SetWith [o] o Source # 
Instance details

Defined in SDP.Set

Methods

setWith :: Compare o -> [o] -> [o] Source #

groupSetWith :: Compare o -> (o -> o -> o) -> [o] -> [o] Source #

insertWith :: Compare o -> o -> [o] -> [o] Source #

deleteWith :: Compare o -> o -> [o] -> [o] Source #

intersectionWith :: Compare o -> [o] -> [o] -> [o] Source #

differenceWith :: Compare o -> [o] -> [o] -> [o] Source #

symdiffWith :: Compare o -> [o] -> [o] -> [o] Source #

unionWith :: Compare o -> [o] -> [o] -> [o] Source #

intersectionsWith :: Foldable f => Compare o -> f [o] -> [o] Source #

differencesWith :: Foldable f => Compare o -> f [o] -> [o] Source #

unionsWith :: Foldable f => Compare o -> f [o] -> [o] Source #

symdiffsWith :: Foldable f => Compare o -> f [o] -> [o] Source #

isIntersectsWith :: Compare o -> [o] -> [o] -> Bool Source #

isDisjointWith :: Compare o -> [o] -> [o] -> Bool Source #

memberWith :: Compare o -> o -> [o] -> Bool Source #

isSubsetWith :: Compare o -> [o] -> [o] -> Bool Source #

subsets :: [o] -> [[o]] Source #

lookupLTWith :: Compare o -> o -> [o] -> Maybe o Source #

lookupGTWith :: Compare o -> o -> [o] -> Maybe o Source #

lookupGEWith :: Compare o -> o -> [o] -> Maybe o Source #

lookupLEWith :: Compare o -> o -> [o] -> Maybe o Source #

Unboxed e => SetWith (SBytes# e) e Source # 
Instance details

Defined in SDP.Prim.SBytes

SetWith (SArray# e) e Source # 
Instance details

Defined in SDP.Prim.SArray

(SetWith1 rep e, Linear1 rep e, Ord (rep e), Bordered1 rep Int e) => SetWith (AnyChunks rep e) e Source # 
Instance details

Defined in SDP.Templates.AnyChunks

Methods

setWith :: Compare e -> AnyChunks rep e -> AnyChunks rep e Source #

groupSetWith :: Compare e -> (e -> e -> e) -> AnyChunks rep e -> AnyChunks rep e Source #

insertWith :: Compare e -> e -> AnyChunks rep e -> AnyChunks rep e Source #

deleteWith :: Compare e -> e -> AnyChunks rep e -> AnyChunks rep e Source #

intersectionWith :: Compare e -> AnyChunks rep e -> AnyChunks rep e -> AnyChunks rep e Source #

differenceWith :: Compare e -> AnyChunks rep e -> AnyChunks rep e -> AnyChunks rep e Source #

symdiffWith :: Compare e -> AnyChunks rep e -> AnyChunks rep e -> AnyChunks rep e Source #

unionWith :: Compare e -> AnyChunks rep e -> AnyChunks rep e -> AnyChunks rep e Source #

intersectionsWith :: Foldable f => Compare e -> f (AnyChunks rep e) -> AnyChunks rep e Source #

differencesWith :: Foldable f => Compare e -> f (AnyChunks rep e) -> AnyChunks rep e Source #

unionsWith :: Foldable f => Compare e -> f (AnyChunks rep e) -> AnyChunks rep e Source #

symdiffsWith :: Foldable f => Compare e -> f (AnyChunks rep e) -> AnyChunks rep e Source #

isIntersectsWith :: Compare e -> AnyChunks rep e -> AnyChunks rep e -> Bool Source #

isDisjointWith :: Compare e -> AnyChunks rep e -> AnyChunks rep e -> Bool Source #

memberWith :: Compare e -> e -> AnyChunks rep e -> Bool Source #

isSubsetWith :: Compare e -> AnyChunks rep e -> AnyChunks rep e -> Bool Source #

subsets :: AnyChunks rep e -> [AnyChunks rep e] Source #

lookupLTWith :: Compare e -> e -> AnyChunks rep e -> Maybe e Source #

lookupGTWith :: Compare e -> e -> AnyChunks rep e -> Maybe e Source #

lookupGEWith :: Compare e -> e -> AnyChunks rep e -> Maybe e Source #

lookupLEWith :: Compare e -> e -> AnyChunks rep e -> Maybe e Source #

(Index i, SetWith1 rep e, Linear1 rep e, Bordered1 rep Int e) => SetWith (AnyBorder rep i e) e Source # 
Instance details

Defined in SDP.Templates.AnyBorder

Methods

setWith :: Compare e -> AnyBorder rep i e -> AnyBorder rep i e Source #

groupSetWith :: Compare e -> (e -> e -> e) -> AnyBorder rep i e -> AnyBorder rep i e Source #

insertWith :: Compare e -> e -> AnyBorder rep i e -> AnyBorder rep i e Source #

deleteWith :: Compare e -> e -> AnyBorder rep i e -> AnyBorder rep i e Source #

intersectionWith :: Compare e -> AnyBorder rep i e -> AnyBorder rep i e -> AnyBorder rep i e Source #

differenceWith :: Compare e -> AnyBorder rep i e -> AnyBorder rep i e -> AnyBorder rep i e Source #

symdiffWith :: Compare e -> AnyBorder rep i e -> AnyBorder rep i e -> AnyBorder rep i e Source #

unionWith :: Compare e -> AnyBorder rep i e -> AnyBorder rep i e -> AnyBorder rep i e Source #

intersectionsWith :: Foldable f => Compare e -> f (AnyBorder rep i e) -> AnyBorder rep i e Source #

differencesWith :: Foldable f => Compare e -> f (AnyBorder rep i e) -> AnyBorder rep i e Source #

unionsWith :: Foldable f => Compare e -> f (AnyBorder rep i e) -> AnyBorder rep i e Source #

symdiffsWith :: Foldable f => Compare e -> f (AnyBorder rep i e) -> AnyBorder rep i e Source #

isIntersectsWith :: Compare e -> AnyBorder rep i e -> AnyBorder rep i e -> Bool Source #

isDisjointWith :: Compare e -> AnyBorder rep i e -> AnyBorder rep i e -> Bool Source #

memberWith :: Compare e -> e -> AnyBorder rep i e -> Bool Source #

isSubsetWith :: Compare e -> AnyBorder rep i e -> AnyBorder rep i e -> Bool Source #

subsets :: AnyBorder rep i e -> [AnyBorder rep i e] Source #

lookupLTWith :: Compare e -> e -> AnyBorder rep i e -> Maybe e Source #

lookupGTWith :: Compare e -> e -> AnyBorder rep i e -> Maybe e Source #

lookupGEWith :: Compare e -> e -> AnyBorder rep i e -> Maybe e Source #

lookupLEWith :: Compare e -> e -> AnyBorder rep i e -> Maybe e Source #

type SetWith1 s o = SetWith (s o) o Source #

Kind (* -> *) SetWith.

Set

class Nullable s => Set s o | s -> o where Source #

Set is a class of data structures, that can represent any sets. Set is intended for more specific sets than ordered linear structures. In particular, it may not work with an arbitrary comparator, and also (unlike the early implementation) does not impose restrictions on the element type.

Set, as well as SetWith, doesn't provide data protection/validation.

Minimal complete definition

Nothing

Methods

set :: s -> s Source #

The same as setWith compare.

default set :: (SetWith s o, Ord o) => s -> s Source #

insert :: o -> s -> s Source #

Same as insert compare.

default insert :: (SetWith s o, Ord o) => o -> s -> s Source #

delete :: o -> s -> s Source #

default delete :: (SetWith s o, Ord o) => o -> s -> s Source #

(/\) :: s -> s -> s Source #

default (/\) :: (SetWith s o, Ord o) => s -> s -> s Source #

(\/) :: s -> s -> s Source #

default (\/) :: (SetWith s o, Ord o) => s -> s -> s Source #

(\\) :: s -> s -> s Source #

default (\\) :: (SetWith s o, Ord o) => s -> s -> s Source #

(\^/) :: s -> s -> s Source #

default (\^/) :: (SetWith s o, Ord o) => s -> s -> s Source #

(/?\) :: s -> s -> Bool Source #

default (/?\) :: (SetWith s o, Ord o) => s -> s -> Bool Source #

(\?/) :: s -> s -> Bool Source #

default (\?/) :: (SetWith s o, Ord o) => s -> s -> Bool Source #

(\+/) :: s -> s -> Bool Source #

default (\+/) :: (SetWith s o, Ord o) => s -> s -> Bool Source #

intersections :: Foldable f => f s -> s Source #

default intersections :: (Foldable f, SetWith s o, Ord o) => f s -> s Source #

unions :: Foldable f => f s -> s Source #

default unions :: (Foldable f, SetWith s o, Ord o) => f s -> s Source #

differences :: Foldable f => f s -> s Source #

default differences :: (Foldable f, SetWith s o, Ord o) => f s -> s Source #

symdiffs :: Foldable f => f s -> s Source #

Same as symdiffsWith compare'.

default symdiffs :: (Foldable f, SetWith s o, Ord o) => f s -> s Source #

member :: o -> s -> Bool Source #

default member :: (SetWith s o, Ord o) => o -> s -> Bool Source #

lookupLT :: Ord o => o -> s -> Maybe o Source #

default lookupLT :: (SetWith s o, Ord o) => o -> s -> Maybe o Source #

lookupGT :: Ord o => o -> s -> Maybe o Source #

default lookupGT :: (SetWith s o, Ord o) => o -> s -> Maybe o Source #

lookupLE :: Ord o => o -> s -> Maybe o Source #

default lookupLE :: (SetWith s o, Ord o) => o -> s -> Maybe o Source #

lookupGE :: Ord o => o -> s -> Maybe o Source #

default lookupGE :: (SetWith s o, Ord o) => o -> s -> Maybe o Source #

Instances

Instances details
Ord o => Set [o] o Source # 
Instance details

Defined in SDP.Set

Methods

set :: [o] -> [o] Source #

insert :: o -> [o] -> [o] Source #

delete :: o -> [o] -> [o] Source #

(/\) :: [o] -> [o] -> [o] Source #

(\/) :: [o] -> [o] -> [o] Source #

(\\) :: [o] -> [o] -> [o] Source #

(\^/) :: [o] -> [o] -> [o] Source #

(/?\) :: [o] -> [o] -> Bool Source #

(\?/) :: [o] -> [o] -> Bool Source #

(\+/) :: [o] -> [o] -> Bool Source #

intersections :: Foldable f => f [o] -> [o] Source #

unions :: Foldable f => f [o] -> [o] Source #

differences :: Foldable f => f [o] -> [o] Source #

symdiffs :: Foldable f => f [o] -> [o] Source #

member :: o -> [o] -> Bool Source #

lookupLT :: o -> [o] -> Maybe o Source #

lookupGT :: o -> [o] -> Maybe o Source #

lookupLE :: o -> [o] -> Maybe o Source #

lookupGE :: o -> [o] -> Maybe o Source #

(Unboxed e, Ord e) => Set (SBytes# e) e Source # 
Instance details

Defined in SDP.Prim.SBytes

Ord e => Set (SArray# e) e Source # 
Instance details

Defined in SDP.Prim.SArray

(Nullable (AnyChunks rep e), SetWith1 (AnyChunks rep) e, Ord e) => Set (AnyChunks rep e) e Source # 
Instance details

Defined in SDP.Templates.AnyChunks

Methods

set :: AnyChunks rep e -> AnyChunks rep e Source #

insert :: e -> AnyChunks rep e -> AnyChunks rep e Source #

delete :: e -> AnyChunks rep e -> AnyChunks rep e Source #

(/\) :: AnyChunks rep e -> AnyChunks rep e -> AnyChunks rep e Source #

(\/) :: AnyChunks rep e -> AnyChunks rep e -> AnyChunks rep e Source #

(\\) :: AnyChunks rep e -> AnyChunks rep e -> AnyChunks rep e Source #

(\^/) :: AnyChunks rep e -> AnyChunks rep e -> AnyChunks rep e Source #

(/?\) :: AnyChunks rep e -> AnyChunks rep e -> Bool Source #

(\?/) :: AnyChunks rep e -> AnyChunks rep e -> Bool Source #

(\+/) :: AnyChunks rep e -> AnyChunks rep e -> Bool Source #

intersections :: Foldable f => f (AnyChunks rep e) -> AnyChunks rep e Source #

unions :: Foldable f => f (AnyChunks rep e) -> AnyChunks rep e Source #

differences :: Foldable f => f (AnyChunks rep e) -> AnyChunks rep e Source #

symdiffs :: Foldable f => f (AnyChunks rep e) -> AnyChunks rep e Source #

member :: e -> AnyChunks rep e -> Bool Source #

lookupLT :: e -> AnyChunks rep e -> Maybe e Source #

lookupGT :: e -> AnyChunks rep e -> Maybe e Source #

lookupLE :: e -> AnyChunks rep e -> Maybe e Source #

lookupGE :: e -> AnyChunks rep e -> Maybe e Source #

(SetWith1 (AnyBorder rep i) e, Nullable (AnyBorder rep i e), Ord e) => Set (AnyBorder rep i e) e Source # 
Instance details

Defined in SDP.Templates.AnyBorder

Methods

set :: AnyBorder rep i e -> AnyBorder rep i e Source #

insert :: e -> AnyBorder rep i e -> AnyBorder rep i e Source #

delete :: e -> AnyBorder rep i e -> AnyBorder rep i e Source #

(/\) :: AnyBorder rep i e -> AnyBorder rep i e -> AnyBorder rep i e Source #

(\/) :: AnyBorder rep i e -> AnyBorder rep i e -> AnyBorder rep i e Source #

(\\) :: AnyBorder rep i e -> AnyBorder rep i e -> AnyBorder rep i e Source #

(\^/) :: AnyBorder rep i e -> AnyBorder rep i e -> AnyBorder rep i e Source #

(/?\) :: AnyBorder rep i e -> AnyBorder rep i e -> Bool Source #

(\?/) :: AnyBorder rep i e -> AnyBorder rep i e -> Bool Source #

(\+/) :: AnyBorder rep i e -> AnyBorder rep i e -> Bool Source #

intersections :: Foldable f => f (AnyBorder rep i e) -> AnyBorder rep i e Source #

unions :: Foldable f => f (AnyBorder rep i e) -> AnyBorder rep i e Source #

differences :: Foldable f => f (AnyBorder rep i e) -> AnyBorder rep i e Source #

symdiffs :: Foldable f => f (AnyBorder rep i e) -> AnyBorder rep i e Source #

member :: e -> AnyBorder rep i e -> Bool Source #

lookupLT :: e -> AnyBorder rep i e -> Maybe e Source #

lookupGT :: e -> AnyBorder rep i e -> Maybe e Source #

lookupLE :: e -> AnyBorder rep i e -> Maybe e Source #

lookupGE :: e -> AnyBorder rep i e -> Maybe e Source #

type Set1 s o = Set (s o) o Source #

Kind (* -> *) Set.