Java Reference
In-Depth Information
1
package weiss.util;
2
3
/**
4
* Collection interface; the root of all 1.5 collections.
5
*/
6
public interface Collection<AnyType> extends Iterable<AnyType>, java.io.Serializable
7
{
8
/**
9
* Returns the number of items in this collection.
10
*/
11
int size( );
12
13
/**
14
* Tests if this collection is empty.
15
*/
16
boolean isEmpty( );
17
18
/**
19
* Tests if some item is in this collection.
20
*/
21
boolean contains( Object x );
22
23
/**
24
* Adds an item to this collection.
25
*/
26
boolean add( AnyType x );
27
28
/**
29
* Removes an item from this collection.
30
*/
31
boolean remove( Object x );
32
33
/**
34
* Change the size of this collection to zero.
35
*/
36
void clear( );
37
38
/**
39
* Obtains an Iterator object used to traverse the collection.
40
*/
41
Iterator<AnyType> iterator( );
42
43
/**
44
* Obtains a primitive array view of the collection.
45
*/
46
Object [ ] toArray( );
47
48
/**
49
* Obtains a primitive array view of the collection.
50
*/
51
<OtherType> OtherType [ ] toArray( OtherType [ ] arr );
52
}
figure 6.9
A sample specification of the
Collection
interface
Search WWH ::
Custom Search