-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCollectionInterface.java
More file actions
84 lines (76 loc) · 1.97 KB
/
CollectionInterface.java
File metadata and controls
84 lines (76 loc) · 1.97 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
public interface CollectionInterface<E>
{
/**
* Determines if this data structure is at its capacity.
*
* @return true - if this data structure is at its capacity; false otherwise.
*/
public boolean is_full();
/**
* Determines if this data structure is empty.
*
* @return true - if this data structure is empty; false otherwise.
*/
public boolean is_empty();
/**
* Determines the number of elements in this data structure.
*
* @return the number of elements currently resident in this
* data structure.
*/
public int size();
/**
* Add a new element at the specified index.
*
* @param index the index where the element is to be added.
* @param e the element to be added.
*
* @return true - if c was added at index; false otherwise.
*/
public boolean add(int index, E e);
/**
* Add a new element at the end of the data structure.
*
* @param e the element to be added.
*
* @return true - if c was added at index; false otherwise.
*/
public boolean add(E e);
/**
* Remove the element at specified index.
*
* @param index - the index of the element to be returned.
*
* @return the element removed.
*
* @throws IndexOutofBoundException - if index is < 0 or >= size().
*
*/
public E remove(int index);
/**
* Remove the 'visited' element.
*
* @return the element removed.
*
*/
public E remove();
/**
* Get the element at specified index.
*
* @param index - the index of the element to be returned.
*
* @return the element at the index.
*
* @throws IndexOutofBoundException - if index is < 0 or >= size().
*
*/
public E get(int index);
/**
* Determine if the element is contained in this list.
*
* @param e the element to be searched for.
*
* @return true - if e was in the list, false otherwise.
*/
public boolean contains(E e);
}