gim v1.2.1 Gim.Index View Source
Internal helper module to handle indexes.
Link to this section Summary
Functions
Adds an id to the given index
Returns the difference of two given indexes
Intersects a list of indexes
Intersects the given indexes
Intersects a list of indexes
Joins the given indexes
Turns a given list into an index
Removes an id from the given index
Link to this section Types
Link to this section Functions
Adds an id to the given index
iex> add([], 42)
[42]
iex> add([404, 23, 13], 42)
[404, 42, 23, 13]
Since ids have to be unique, duplicates are prevented
iex> add([404, 42, 23, 13], 42)
[404, 42, 23, 13]
Returns the difference of two given indexes
iex> difference([99, 66, 77, 50, 30, 10, 0], [99, 70, 60, 50, 11, 10, 1, 0])
{[77, 66, 30], [70, 60, 11, 1]}
iex> difference([5, 4, 3, 2, 1], [5, 4, 3, 2, 1])
{[], []}
iex> difference([], [])
{[], []}
Intersects a list of indexes
iex> intersect([[99, 77, 66, 50, 30, 10, 0], [99, 70, 60, 50, 11, 10, 1, 0], [99, 50, 10]])
[99, 50, 10]
Intersects the given indexes
iex> intersect([99, 66, 77, 50, 30, 10, 0], [99, 70, 60, 50, 11, 10, 1, 0])
[99, 50, 10, 0]
iex> intersect([], [99, 70, 60, 50, 11, 10, 1, 0])
[]
Intersects a list of indexes
iex> join([[99, 55, 42, 11], [98, 54, 42, 10], [90, 50, 42]])
[99, 98, 90, 55 , 54, 50, 42, 11, 10]
Joins the given indexes
iex> join([99, 50, 13], [90, 50, 10])
[99, 90, 50, 13, 10]
iex> join([], [99, 70, 60, 50, 11, 10, 1, 0])
[99, 70, 60, 50, 11, 10, 1, 0]
Turns a given list into an index
iex> new([10, 13, 6, 60, 2])
[60, 13, 10, 6, 2]
iex> new([2, 2, 2, 3])
[3, 2]
Removes an id from the given index
iex> remove([], 42)
[]
iex> remove([404, 42, 23, 13], 42)
[404, 23, 13]