Coconut Framework  beta
Classes | Functions
CNList.h File Reference

Define CNList data structure. More...

#include "CNListItem.h"
#include "CNType.h"

Go to the source code of this file.

Classes

struct  CNList
 List of pointers. More...
 

Functions

static struct CNList CNMakeEmptyList (struct CNResource *resource)
 Initialize CNList. More...
 
void CNDestroyList (struct CNList *dst)
 Destroy CNObject(s) in the list and list items. More...
 
static size_t CNCountOfItemsInList (const struct CNList *src)
 Get count of items in the list. More...
 
static struct CNListItemCNFirstListItem (const struct CNList *src)
 Get 1st item in the list. More...
 
static struct CNListItemCNLastListItem (const struct CNList *src)
 Get last item in the list. More...
 
static struct CNListItemCNCentinelListItem (const struct CNList *src)
 Get centinel item of the list. More...
 
void CNAppendItemToList (struct CNList *dst, void *src)
 Append object to the list. More...
 
void CNPrependItemToList (struct CNList *dst, void *src)
 Prepend object to the list. More...
 
struct CNList CNCopyList (const struct CNList *src)
 Make the copy of source list. More...
 
void CNInsertItemToList (struct CNList *owner, struct CNListItem *prev, void *src)
 Insert item to the list. More...
 
void CNInsertItemsToList (struct CNList *owner, struct CNListItem *prev, const struct CNList *src)
 Insert items to the list. More...
 
void * CNUnlinkItemFromList (struct CNList *owner, struct CNListItem *dst)
 Unlink an item from the list and return it's data. More...
 
void * CNUnlinkFirstItemFromList (struct CNList *dst)
 Get and unlink 1st item in the list. More...
 
void * CNUnlinkLastItemFromList (struct CNList *dst)
 Get and unlink last item in the list. More...
 
void CNMoveList (struct CNList *dst, struct CNList *src)
 Move items from source to destination. More...
 
void CNAppendItemsToList (struct CNList *dst, struct CNList *src)
 Copy items from source to destination. More...
 
struct CNListItemCNSearchDataInList (const struct CNList *list, void *data)
 Search list item which has source data reference. More...
 
struct CNListItemCNSearchMatchedDataInList (const struct CNList *list, CNMatchDataFuncRef func, void *info)
 Search list item which matched source data. More...
 

Detailed Description

Define CNList data structure.

Copyright
Copyright (C) 2012 Steel Wheels Project

Function Documentation

static struct CNList CNMakeEmptyList ( struct CNResource *  resource)
static

Initialize CNList.

Returns
Initialized list
Parameters
resourceResource for the list

References CNList::centinelItem, CNAllocateListItem(), CNList::itemCount, and CNList::resource.

Referenced by CNMakeEmptyObjectList().

void CNDestroyList ( struct CNList dst)

Destroy CNObject(s) in the list and list items.

Parameters
dstDestination list
static size_t CNCountOfItemsInList ( const struct CNList src)
inlinestatic

Get count of items in the list.

Returns
Count of the items
Parameters
srcSource list

References CNList::itemCount.

Referenced by CNCountOfObjectsInList().

static struct CNListItem* CNFirstListItem ( const struct CNList src)
static

Get 1st item in the list.

Returns
First item
Parameters
srcSource list

References CNListItem::_nextItem, and CNList::centinelItem.

Referenced by CNFirstListObject().

static struct CNListItem* CNLastListItem ( const struct CNList src)
static

Get last item in the list.

Returns
Last item
Parameters
srcSource list

References CNListItem::_prevItem, and CNList::centinelItem.

Referenced by CNLastListObject().

static struct CNListItem* CNCentinelListItem ( const struct CNList src)
static

Get centinel item of the list.

Returns
Centinel item
Parameters
srcSource list

References CNList::centinelItem.

Referenced by CNCentinelListObject().

void CNAppendItemToList ( struct CNList dst,
void *  src 
)

Append object to the list.

Parameters
dstDestination list
srcSource object

Referenced by CNAppendObjectToList().

void CNPrependItemToList ( struct CNList dst,
void *  src 
)

Prepend object to the list.

Parameters
dstDestination list
srcSource object

Referenced by CNPrependObjectToList().

struct CNList CNCopyList ( const struct CNList src)

Make the copy of source list.

Returns
Copied list
Parameters
srcSource list
void CNInsertItemToList ( struct CNList owner,
struct CNListItem prev,
void *  src 
)

Insert item to the list.

Parameters
ownerDestination list
prevItem in the owner list, the source data will be linked as the next of this.
srcSource data

Referenced by CNInsertObjectToList().

void CNInsertItemsToList ( struct CNList owner,
struct CNListItem prev,
const struct CNList src 
)

Insert items to the list.

Parameters
ownerDestination list
prevItem in the owner list, the source data will be linked as the next of this.
srcSource data list
void* CNUnlinkItemFromList ( struct CNList owner,
struct CNListItem dst 
)

Unlink an item from the list and return it's data.

Returns
Data for unlinked item
Parameters
ownerDestination list
dstDestination list item to be removed

Referenced by CNUnlinkObjectFromList().

void* CNUnlinkFirstItemFromList ( struct CNList dst)

Get and unlink 1st item in the list.

Return values
dataPointer of the 1st item
NULLThere are not items in the list
Parameters
dstSource and destination list After this operation, the 1st item will be removed from list

Referenced by CNUnlinkFirstObjectFromList().

void* CNUnlinkLastItemFromList ( struct CNList dst)

Get and unlink last item in the list.

Return values
dataPointer of the 1st item
NULLThere are not items in the list
Parameters
dstSource and destination list After this operation, the last item will be removed from list

Referenced by CNUnlinkLastObjectFromList().

void CNMoveList ( struct CNList dst,
struct CNList src 
)

Move items from source to destination.

Parameters
dstDestination list
srcSource list

Referenced by CNMoveObjectList().

void CNAppendItemsToList ( struct CNList dst,
struct CNList src 
)

Copy items from source to destination.

Parameters
dstDestination list
srcSource list
struct CNListItem* CNSearchDataInList ( const struct CNList list,
void *  data 
)

Search list item which has source data reference.

Return values
listitemThe list item which has source data
NULLThere are no list item
Parameters
listList to be searched
dataSource data

Referenced by CNSearchObjectInList().

struct CNListItem* CNSearchMatchedDataInList ( const struct CNList list,
CNMatchDataFuncRef  func,
void *  info 
)

Search list item which matched source data.

Return values
listitemThe list item which mached with source data
NULLThere are no list item
Parameters
listList to be searched
funcMaching function
infoMaching information

Referenced by CNSearchMatchedObjectInList().