-
Notifications
You must be signed in to change notification settings - Fork 2
/
iface.go
55 lines (54 loc) · 1.62 KB
/
iface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package splaytree
// Interface defines the public interface of splay trees
type Interface interface {
// Remove all elements of the tree
Clear()
// Count the number of elements in the tree
Count() int
// Remove an item from the tree
Delete(item Item) Item
// Remove all given items from the tree
DeleteAll(items []Item) int
// Remove the largest element of the tree
DeleteMax() Item
// Remove the smallest element of the tree
DeleteMin() Item
// Remove and return the element at the root
DeleteRoot() Item
// Clone the tree
Duplicate() Interface
// Compute the height of the tree
Height() int
// Infimum gives the closest smaller item
Infimum(item Item) Item
// Add a new item to the tree (if unique)
Insert(item Item) bool
// Add a number of items to the tree
InsertAll(items []Item) int
// Create a new iterator over this tree.
Iterator() func() Item
// Join two trees with cost O(N + M), which is optimal.
Join(other Interface)
// Lookup an item
Lookup(item Item) Item
// Give the largest element
Max() Item
// Give the smallest element
Min() Item
// Test if the tree contains at least one element
NonEmpty() bool
// Create an iterator for a limited range of items
RangeIterator(lower Item, upper Item) func() Item
// Insert or replace an element
Replace(item Item) bool
// Insert or replace a number of elements
ReplaceAll(items []Item) int
// Create an iterator which iterates in descending order
ReverseIterator() func() Item
// Give the current root element
Root() Item
// Supremum gives the closest larger item
Supremum(item Item) Item
// Traverse a tree inorder with a function
Traverse(func(Item))
}