-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDSInterfaces.java
60 lines (55 loc) · 1.79 KB
/
DSInterfaces.java
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
56
57
58
59
60
/**
* An interface detailing the basic constructs all data structures should have.
* You shouldn't be implementing this directly, but using the other interfaces below.
*/
public interface IDS<T implements Comparable<T>> extends Iterable{
public void add(T toAdd);
public boolean contains(T t);
public List<T> asList();
public String toString();
public int size();
public void empty(); //Removes all elements from the data structure
}
/**
* A linked list interface. It describes a list built from individual parts.
* Please implement both a singly and doubly linked list.
*/
public interface ILinkedList<T implements Comparable<T>> extends IDS<T> {
public void sort();
public T getFirst();
public T getLast();
public T get(int i); //Zero-based
}
/**
* A Queue interface. Think of a queue at the grocery store.
* Please write a queue and a priority queue.
* The priority queue should access smaller elements first.
*/
public interface IQueue<T implements Comparable<T>> extends IDS<T> {
public void enqueue(T t);
public T dequeue();
}
/**
* A stack interface. Think of a stack of plates.
*/
public interface IStack<T implements Comparable<T>> extends IDS<T> {
public void push(T t);
public T pop();
}
/**
* A binary tree interface.
* Please use this to implement a binary search tree.
*/
public interface IBTree<T implements Comparable<T>> extends IDS<T> {
public Iterator<T> inOrder();
public Iterator<T> postOrder();
public Iterator<T> preOrder();
}
/**
* A map interface. It associates a Key with a Value.
* Please write (a) a map that uses hashes and (b) a map that uses your IBTree implementation.
*/
public interface IMap<K implements Comparable<T>, V> extends IDS<K> {
public void set(K key, V val);
public V get(K key);
}