Containers
Eina » Data Types

Data types that contains other types. More...

## Topics

| Array
| These functions provide array management.
| Compact List
| Eina_Clist is a compact (inline) list implementation.
| Hash Table
| Hash table management.
| Inline Array
| Inline array is a container that stores the data itself, not the pointers to the data.
| Inline List
| These functions provide inline list management.
| List
| These functions provide double linked list management.
| Sparse Matrix
| These functions manage sparse matrices.
| Quaternion
| Red-Black tree
| These functions provide Red-Black tree management.
| Safe Pointer
| These functions provide a wrapper that protect access to pointers
| Trash
| This group provides a generic container.
| Generic Value Storage
| Abstracts generic data storage and access to it in an extensible and efficient way.

## Detailed Description

Data types that contains other types.

Examples: list, array and hash.

# Introduction

Containers are data types that hold data and allow iteration over their elements with an Iterator Functions, or eventually an Accessor Functions.

The containers in eina are designed with performance in mind, one consequence of this is that they don't check the validity of data structures given to them(Magic).

# Choosing container type

The choice of which container to use in each situation is very important in achieving good performance and readable code. The most common container types used are:

- List
- Inline list
- Array
- Inline array
- Hash

All types have pros and cons. The following considerations are good starting point in deciding which container to use:

- Hashes are appropriate for datasets which will be searched often.
- Arrays are good when accessing members by position;
- Lists provide good versatility for adding elements in any position with minimal overhead.
- Inline arrays use very little memory and don't cause fragmentation so are a good option in memory constrained systems.
- Inline lists are the best type to use when list flexibility is required but no pointer indirection overhead can be allowed.
  Warning
    These are general considerations. Every situation is different. Don't follow these recommendations blindly.

# Creating custom container types

Note
  Before creating a custom container check if any of the existing ones suit your needs. For example, while there is no stack type Array is a very good substitute. Similarly there is no queue type however an List works very well as a queue.

If creating a custom container type, consider allowing access to the data in your container through Iterators and Accessors. To do so your container should have an iterator creation function and an accessor creation function. These functions should return properly populated _Eina_Iterator and _Eina_Accessor.