The Container Class
[The Classes]

The base class of all containers. More...


Data Structures

struct  Cmaid_Container
 The Container Class structure This is the base structure of every container. Do not manipulate the attributes directly. More...

Modules

 The Container Interface

Defines

#define CMAID_CONTAINER(c)   ((Cmaid_Container *)(c))
 Typecast a pointer to a Cmaid_Container pointer.

Typedefs

typedef struct Cmaid_Container Cmaid_Container
 Type definition of the Container Class.

Functions

CMAID_INLINE int cmaid_container_count (const Cmaid_Container *c)
 Retrieve the memeber count of the container.
CMAID_INLINE int cmaid_container_empty_is (const Cmaid_Container *c)
CMAID_INLINE void cmaid_container_clear (Cmaid_Container *c)
 Remove and free every item from the container.
CMAID_INLINE void cmaid_container_iter_attach (Cmaid_Container *c, Cmaid_Iter *it)
 Attach an iterator to the container.
CMAID_INLINE void cmaid_container_iter_detach (Cmaid_Container *c, Cmaid_Iter *it)
 Detach an iterator of the container.
CMAID_INLINE void cmaid_container_destroy (Cmaid_Container *c)
 Destroy the container and its nodes.


Detailed Description

The base class of all containers.

The container class builds the base of all containers, therefor it needs to be general a does not provides any function that are related to the underlying container layout, e.g. if the container is ordered or not, if objects may appear twice etc.


Function Documentation

CMAID_INLINE void cmaid_container_clear ( Cmaid_Container c  ) 

Remove and free every item from the container.

Parameters:
c the container to clear
Returns:
Return no value This function removes every item inside of the container, if there is a free function defined the item will be freed. Hence don't used items after you called that function.

CMAID_INLINE int cmaid_container_count ( const Cmaid_Container c  ) 

Retrieve the memeber count of the container.

Parameters:
c the container to retrieve the child count
Returns:
Returns the number of items inside of the container This function return the number of items inside of a container. It is guaranteed to be a O(1) operation.

CMAID_INLINE void cmaid_container_destroy ( Cmaid_Container c  ) 

Destroy the container and its nodes.

Parameters:
c the container to destroy
Returns:
Returns no value This will clear the container and free the memory it was using. You cannot use the container after it was destroyed.

CMAID_INLINE int cmaid_container_empty_is ( const Cmaid_Container c  ) 

Parameters:
c the container to retrieve fill state
Returns:
Returns TRUE if the container is empty else FALSE

CMAID_INLINE void cmaid_container_iter_attach ( Cmaid_Container c,
Cmaid_Iter it 
)

Attach an iterator to the container.

Parameters:
c the container to attach the iterator
it the iterator to attach Attach an iterator to the given container. The iterator will point to the virtual -1 item, i.e. before the very first item of the container. The iterator needs to point valud memory. Don't forget to detach the iterator after you used it. A normal usage case looks like this:
 Cmaid_Iter it;
 const char *item;

 cmaid_container_iter_attach(c, &it);
 while ((item = cmaid_iter_next(&it)))
     printf("%s\n", item);

 cmaid_container_iter_detach(c, &it);

CMAID_INLINE void cmaid_container_iter_detach ( Cmaid_Container c,
Cmaid_Iter it 
)

Detach an iterator of the container.

Parameters:
c the container to detach the iterator
it the iterator to detach This will remove the iterator from the internal iterator list. It is important that you call the function after the iterator goes to be invalid, i.e. after it is freed or is going to be out of scope.


Generated on Wed Aug 5 00:20:49 2009 for Cmaid by  doxygen 1.5.8