Tizen Native API  3.0
Containers

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 to be used are:

  • List
  • Inline list
  • Array
  • Inline array
  • Hash

All types have virtues and vices. 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 and therefore are a good option in memory constrained systems;
  • inline lists are the appropriate type to use when the flexibility of a list is required but the overhead of pointer indirection is not acceptable.
    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 one of the existing ones doesn't 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.