Skip to content

Commit

Permalink
Merge pull request #1 from walter-weinmann/wwe_persistance
Browse files Browse the repository at this point in the history
Version 1.1.0: Pluggable sort function.
  • Loading branch information
walter-weinmann authored Nov 21, 2016
2 parents c2e2009 + 221f12c commit 3398895
Show file tree
Hide file tree
Showing 7 changed files with 1,686 additions and 1,580 deletions.
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This module considers two keys as different if and only if they do not compare e

### Data Structure ###

{MinimumSubtrees, MaximumKeys, NumberKeyValues, Tree}
{MinimumSubtrees, MaximumKeys, NumberKeyValues, SortFunction, Tree}

Tree is composed of nodes of the form

Expand All @@ -34,7 +34,7 @@ Since the trees are always balanced, there is no need for a balance operation.

## DATA TYPES ##

b_tree() = {pos_integer(), pos_integer(), non_neg_integer(), tree()}
b_tree() = {pos_integer(), pos_integer(), non_neg_integer(), sort_function(), tree()}

A general balanced tree.

Expand Down Expand Up @@ -70,7 +70,17 @@ Types:
Order = pos_integer()
B-Tree = b_tree()

Returns a new empty b-tree. Order is defined as the maximum number of children nodes a non-leaf node may hold. The minimum value is 4.
Returns a new empty b-tree. Order is defined as the maximum number of children nodes a non-leaf node may hold. The minimum value is 4. The sort order of the key values is ascending.

### empty (Order, Function) -> B-Tree ###

Types:

Order = pos_integer()
Function = fun((Key1, Key2) -> equal | greater | less)
B-Tree = b_tree()

Returns a new empty b-tree. Order is defined as the maximum number of children nodes a non-leaf node may hold. The minimum value is 4. The sort order of the key values is defined by the given function, which takes two key values and returns one of the atoms **equal**, **greater** or **less**.

### enter (Key, Value, B-Tree1) -> B-Tree2 ###

Expand Down Expand Up @@ -233,6 +243,24 @@ Types:

Returns tuple {Key, Value}, where Key is the smallest key in B-Tree, and Value is the value associated with this key. Assumes that B-Tree is not empty.

### sort_ascending (Key_1, Key_2) -> equal | greater | less ###

Types:

Key_1 = Key_2 = any()
equal = greater = less = atom()

Returns **greater** if Key_1 > Key_2, **less** if Key_1 < Key_2 and **equal** elsewise.

### sort_dscending (Key_1, Key_2) -> equal | greater | less ###

Types:

Key_1 = Key_2 = any()
equal = greater = less = atom()

Returns **less** if Key_1 > Key_2, **greater** if Key_1 < Key_2 and **equal** elsewise.

### take_largest (B-Tree1) -> {Key, Value, B-Tree2} ###

Types:
Expand Down
Loading

0 comments on commit 3398895

Please sign in to comment.