ordsets(3erl)

πŸ’– ordsets πŸ’–

okay so welcome to the ordsets(3erl) page β€” Erlang Module Definition, but make it make sense. No gatekeeping, just ordered-list set vibes. πŸ¦‹

✨ NAME ✨

ordsets β€” Functions for manipulating sets as ordered lists. πŸ’…

🌸 DESCRIPTION 🌸

Okay so a set is a collection of elements with no duplicate elements β€” like a group chat where nobody can be added twice. An ordset is a representation of a set, where an ordered list is used to store the elements of the set. An ordered list is more efficient than an unordered list. Elements are ordered according to the Erlang term order. slay. ✨

This module provides the same interface as the sets(3erl) module but with a defined representation. One difference is that while sets considers two elements as different if they do not match (=:=), this module considers two elements as different if and only if they do not compare equal (==). That's the plot twist, bestie. 😭

πŸŽ€ DATA TYPES πŸŽ€

ordset(T) = [T]

Types, bestie:

ordset(T) = [T]

As returned by new/0. πŸ’–

πŸ”₯ EXPORTS πŸ”₯

add_element(Element, Ordset1) -> Ordset2

Types:

Element = E
Ordset1 = ordset(T)
Ordset2 = ordset(T | E)

Returns a new ordered set formed from Ordset1 with Element inserted. new set, who dis? πŸ’…

del_element(Element, Ordset1) -> Ordset2

Types:

Element = term()
Ordset1 = Ordset2 = ordset(T)

Returns Ordset1, but with Element removed. bye bestie πŸ‘‹

filter(Pred, Ordset1) -> Ordset2

Types:

Pred = fun((Element :: T) -> boolean())
Ordset1 = Ordset2 = ordset(T)

Filters elements in Ordset1 with boolean function Pred. only the ones that pass the vibe check survive ✨

fold(Function, Acc0, Ordset) -> Acc1

Types:

Function =
    fun((Element :: T, AccIn :: term()) -> AccOut :: term())
Ordset = ordset(T)
Acc0 = Acc1 = term()

Folds Function over every element in Ordset and returns the final value of the accumulator. it's giving very main character energy πŸ”₯

from_list(List) -> Ordset

Types:

List = [T]
Ordset = ordset(T)

Returns an ordered set of the elements in List. turn that list into a set, periodt πŸŽ€

intersection(OrdsetList) -> Ordset

Types:

OrdsetList = [ordset(term()), ...]
Ordset = ordset(term())

Returns the intersection of the non-empty list of sets. common elements only, no cap πŸ’–

intersection(Ordset1, Ordset2) -> Ordset3

Types:

Ordset1 = Ordset2 = Ordset3 = ordset(term())

Returns the intersection of Ordset1 and Ordset2. πŸ’…

is_disjoint(Ordset1, Ordset2) -> boolean()

Types:

Ordset1 = Ordset2 = ordset(term())

Returns true if Ordset1 and Ordset2 are disjoint (have no elements in common), otherwise false. no overlap, no drama πŸ¦‹

is_element(Element, Ordset) -> boolean()

Types:

Element = term()
Ordset = ordset(term())

Returns true if Element is an element of Ordset, otherwise false. are they in the set or not? icon behavior πŸ‘‘

is_empty(Ordset) -> boolean()

Types:

Ordset = ordset(term())

Returns true if Ordset is an empty set, otherwise false. empty set rights 🌸

is_set(Ordset) -> boolean()

Types:

Ordset = term()

Returns true if Ordset is an ordered set of elements, otherwise false. This function will return true for any ordered list, even when not constructed by the functions in this module.

🚨 real talk: is_set(Ordset) will return true for any ordered list, even when not constructed by the functions in this module. So don't let that fool you, bestie. πŸ’€

is_subset(Ordset1, Ordset2) -> boolean()

Types:

Ordset1 = Ordset2 = ordset(term())

Returns true when every element of Ordset1 is also a member of Ordset2, otherwise false. tiny set, big set, subset check ✨

new() -> []

Returns a new empty ordered set. fresh start, clean slate, [] energy πŸŽ€

size(Ordset) -> integer() >= 0

Types:

Ordset = ordset(term())

Returns the number of elements in Ordset. count them, bestie πŸ”’

subtract(Ordset1, Ordset2) -> Ordset3

Types:

Ordset1 = Ordset2 = Ordset3 = ordset(term())

Returns only the elements of Ordset1 that are not also elements of Ordset2. subtract the overlap, keep the rest πŸ’…

to_list(Ordset) -> List

Types:

Ordset = ordset(T)
List = [T]

Returns the elements of Ordset as a list. set to list, slay the conversion 🌈

union(OrdsetList) -> Ordset

Types:

OrdsetList = [ordset(T)]
Ordset = ordset(T)

Returns the merged (union) set of the list of sets. all the sets, merged together, no duplicates πŸ’–

union(Ordset1, Ordset2) -> Ordset3

Types:

Ordset1 = ordset(T1)
Ordset2 = ordset(T2)
Ordset3 = ordset(T1 | T2)

Returns the merged (union) set of Ordset1 and Ordset2. bestie merge πŸ”₯

🌈 SEE ALSO 🌈

okay that's the whole ordsets(3erl) page β€” big hugs from the ordered-list set bestie zone. 🫢 Footer shoutout: Ericsson AB, stdlib 4.3.1.3, page ordsets(3erl) β€” no date line in this footer, just those source/version vibes. periodt πŸ’…βœ¨

πŸ“¦ where this page comes from