IdrisDoc: Data.SortedBag

Data.SortedBag

wrappedBagIso : Iso (SortedMap k PosNat) (SortedBag k)

An Isomorphism between a wrapped and unwrapped bag

unwrapBag : SortedBag k -> SortedMap k PosNat

Remove the BagWrapper from a bag (the required proof from PosNat makes
this safe)

union : EndoChain (fromInteger 2) (SortedBag k)

Merge two bags

toList : SortedBag k -> List k

Convert a Sorted Bag to a List, keeping it sorted.

singleton : Ord k => k -> SortedBag k

A single item (more efficient than insert x empty)

onMaps : OnMapsT n k

Apply an n-ary function over the wrapped SortedMap.

onMap : OnMapsT (fromInteger 1) k

Special case for n=1 for onMaps

null : SortedBag k -> Bool

O(1). Are there any items? The proof in PosNat ensures that there are no
zero-counted items.

insertN : Nat -> UpdateBag k

insert a given number of items

insert : UpdateBag k

insert a single item.

fromList : Ord k => List k -> SortedBag k

Convert a list to a Sorted Bag

empty : Ord k => SortedBag k

An empty bag.

deleteN : Nat -> UpdateBag k

delete a given number of items

delete1 : UpdateBag k

delete 1 item (equivalent to deleteN 1)

delete : UpdateBag k

Delete all ocurances

countMap : k -> SortedMap k PosNat -> Nat

Perform a count on the underlying SortedMap

count : k -> SortedBag k -> Nat

Count the number of occurances

contains : k -> SortedBag k -> Bool

Is a count non-zero?

alterCounts : (Nat -> Nat) -> UpdateBag k

Apply a function (Nat -> Nat) to a given argument

UpdateBag : Type -> Type

The type of insert and the common core of most functions that update
the contests of a Bag.

data SortedBag : Type -> Type
BagWrapper : SortedMap k PosNat -> SortedBag k
OnMapsT : Nat -> Type -> Type

A type for converting a function from an operation over SortedMaps to an
operation over SortedBags