/ cat / container
Native Container Classes
The Gambas interpreter offers you two types of native container classes:

## Arrays

An array is a set of values indexed by an Integer that are consecutive in memory.

All the values in an array have the same datatype, and there is one array class for each native datatype, except Boolean.

See Native Arrays for more information.

Arrays can be multi-dimensional, i.e. values are indexed by more than one Integer.

If an array has one dimension, then it can be shrinked or expanded dynamically, with the Resize method.

## Collections

A Collection is a set of values indexed by a String.

Only Variant values can be stored in a Collection.

The values are internally stored in a hash table that grows dynamically when more and more elements are inserted in it.

## Which one use ?

Here is a short comparison between the three kind of container classes:

Container Comparison Chart

| Array | Collection
--- | --- | ---
Internal storage | One memory block. | Hash table. It means one array of slots, each one being a linked list of values having the same hash code.
Key datatype | Integer | String
Access speed | Immediate The access is immediate. | Fast The key must be compared with all other keys having the same hash code.
Insertion speed | Immediate or Slow The memory block is sometimes resized if needed. And inserting in the middle of the array needs moving part of the memory block. | Fast or Slow The key hash code gives a index into a linked list of memory slots. The hash table have to be resized and recalculated sometimes to keep the access fast.
Deletion speed | Immediate or Slow The memory block is sometimes resized if needed. And deleting in the middle of the array needs moving part of the memory block. | Fast or Slow Once the element is found, the deletion is immediate. The hash table have to be resized and recalculated sometimes to keep the access fast.

### See also

Byte[] Short[] Integer[] Long[] Single[] Float[] Date[] String[] Object[] Pointer[] Variant[] Collection