Game Development Reference
In-Depth Information
Fig. 12.2
An overview of the classes and interfaces related to collections
12.6 The
Collection
Interface
The library
System.Collection.Generic
contains more than only
IList
and
List
.Fig-
ure
12.2
shows an overview of the interfaces and classes that are part of the library.
There is a distinction between two kinds of interface:
•
ISet
, for data where the order does not matter;
•
IList
, for ordered data.
These are a number of methods (not all of them) that are specified in the interface
ICollection
:
interface
ICollection<E>
{
void
Add (E x);
bool
Remove (E x);
bool
Contains (E x);
int
Count {
get
;};
// a read
−
only property
void
Clear ();
}
All methods where an index is needed (in other words: methods requiring
ordered
data), are in the sub-interface
IList
:
interface
IList<E> : ICollection<E>
{
E
this
[
int
n] {
get
;
set
;};
// this is the notation for defining indexing
int
IndexOf (E x);
void
Insert (
int
n, E x);
void
RemoveAt (
int
n);
}