NuSMV/code/nusmv/core/utils/list.h File Reference

Go to the source code of this file.

Data Structures

struct  ls_dummy

Defines

#define LS_AFTER   2
 Set spot after object.
#define LS_BADPARAM   -2
 Bad parameter value.
#define LS_BADSTATE   -3
 Bad generator state.
#define LS_BEFORE   1
 Set spot before object.
#define LS_COPY   (LS_PFLSG) (-1)
 Used for LS_PFLSG to copy a list.
#define LS_DEFINED
#define LS_DELETE   4
 Delete generated item.
#define LS_NH   (lsHandle *) 0
 For all those routines that take a handle, this macro can be used when no handle is required.
#define LS_NIL   0
 Nil for lsList.
#define LS_NOMORE   -1
 No more items.
#define LS_OK   0
 Succeeded operation.
#define LS_STOP   3
 Stop generating items.
#define lsForEachItem(list,gen,data)
 Macro for iteration.

Typedefs

typedef lsGeneric(* LS_PFLSG )(lsGeneric)
typedef ls_dummylsGen
typedef void * lsGeneric
 Arbitrary pointer to data.
typedef ls_dummylsHandle
typedef ls_dummylsList
typedef int lsStatus
 Used for return codes.

Functions

lsList lsAppend (lsList, lsList, LS_PFLSG)
 Append two lists.
lsStatus lsBackeach (lsList list, lsStatus(*userFunc)(lsGeneric, lsGeneric), lsGeneric arg)
 Like lsForeach, but in reversed order.
lsList lsCopy (lsList, LS_PFLSG)
 Copies the contents of a list.
lsList lsCopyListList (lsList)
 Copies the contents of a list of lists of ground.
lsList lsCreate (void)
 Create a new list.
lsStatus lsDelAfter (lsGen, lsGeneric *)
 Delete the item after the current spot.
lsStatus lsDelBefore (lsGen, lsGeneric *)
 Delete the item before the current spot.
lsStatus lsDelBegin (lsList, lsGeneric *)
 Delete first item of a list.
lsStatus lsDelEnd (lsList, lsGeneric *)
 Delete last item of a list.
lsStatus lsDestroy (lsList, void(*)(lsGeneric))
 Delete a previously created list.
lsStatus lsDestroyListList (lsList)
 Delete a previously created list of lists of ground.
lsGen lsEnd (lsList)
 Begin generation at end of list.
lsGeneric lsFetchHandle (lsHandle)
 Returns data associated with handle.
lsStatus lsFinish (lsGen)
 End generation of items in a list.
lsStatus lsFirstItem (lsList, lsGeneric *, lsHandle *)
 Gets the first item of a list.
lsStatus lsForeach (lsList list, lsStatus(*userFunc)(lsGeneric, lsGeneric), lsGeneric arg)
 Calls given function to all element of the list.
lsGen lsGenHandle (lsHandle, lsGeneric *, int)
 Produces a generator given a handle.
lsStatus lsInAfter (lsGen, lsGeneric, lsHandle *)
 Insert an item after the most recently generated by lsNext.
lsStatus lsInBefore (lsGen, lsGeneric, lsHandle *)
 Insert an item before the most recently generated by lsNext.
void lsJoin (lsList, lsList, LS_PFLSG)
 Append second list to first list.
lsStatus lsLastItem (lsList, lsGeneric *, lsHandle *)
 Gets the last item of a list.
int lsLength (lsList)
 Returns the length of the list.
lsStatus lsNewBegin (lsList, lsGeneric, lsHandle *)
 Add item to start of list.
lsStatus lsNewEnd (lsList, lsGeneric, lsHandle *)
 Add item to end of list.
lsStatus lsNext (lsGen, lsGeneric *, lsHandle *)
 Generate next item in sequence.
lsStatus lsPrev (lsGen, lsGeneric *, lsHandle *)
 Generate previous item in sequence.
lsList lsQueryHandle (lsHandle)
 Returns the list of a handle.
lsStatus lsRemoveItem (lsHandle, lsGeneric *)
 Removes item associated with handle from list.
lsList lsSingleton (lsGeneric, lsHandle *)
 Create a new list containing one element.
lsStatus lsSort (lsList, int(*compare)(char *, char *))
 Sorts a list.
lsGen lsStart (lsList)
 Begin generation of items in a list.
lsStatus lsUniq (lsList, int(*compare)(char *, char *), void(*delFunc)(lsGeneric))
 Removes duplicates from a sorted list.

Define Documentation

#define LS_AFTER   2

Set spot after object.

#define LS_BADPARAM   -2

Bad parameter value.

#define LS_BADSTATE   -3

Bad generator state.

#define LS_BEFORE   1

Set spot before object.

#define LS_COPY   (LS_PFLSG) (-1)

Used for LS_PFLSG to copy a list.

#define LS_DEFINED
Todo:
Missing synopsis
Todo:
Missing description
#define LS_DELETE   4

Delete generated item.

#define LS_NH   (lsHandle *) 0

For all those routines that take a handle, this macro can be used when no handle is required.

#define LS_NIL   0

Nil for lsList.

#define LS_NOMORE   -1

No more items.

#define LS_OK   0

Succeeded operation.

#define LS_STOP   3

Stop generating items.

#define lsForEachItem ( list,
gen,
data   ) 
Value:
for(gen = lsStart(list);                                     \
      (lsNext(gen, (lsGeneric *) &data, LS_NH) == LS_OK)       \
      || ((void) lsFinish(gen), 0);                            \
      )

Macro for iteration.

Macro to iterate the items of a list. Note the following: 1) in a for loop, the test is evaluate before the first time through the body 2) the logical OR operator guarantees left to right evaluation, and the second operand is not evaluated if first operand evaluates to non-zero 3) the comma operator returns the value of its second argument.


Typedef Documentation

typedef ls_dummy* lsGen
typedef void* lsGeneric

Arbitrary pointer to data.

typedef ls_dummy* lsHandle
typedef ls_dummy* lsList
Todo:
Missing synopsis
Todo:
Missing description
typedef int lsStatus

Used for return codes.


Function Documentation

lsList lsAppend ( lsList  ,
lsList  ,
LS_PFLSG   
)

Append two lists.

lsStatus lsBackeach ( lsList  list,
lsStatus(*)(lsGeneric, lsGeneric userFunc,
lsGeneric  arg 
)

Like lsForeach, but in reversed order.

This routine is just like lsForeach except it generates all items in `list' from the last item to the first.

See also:
lsForeach
lsList lsCopy ( lsList  ,
LS_PFLSG   
)

Copies the contents of a list.

Returns a copy of list `list'. If `copyFunc' is non-zero, it will be called for each item in `list' and the pointer it returns will be used in place of the original user data for the item in the newly created list. The form of `copyFunc' should be: lsGeneric copyFunc(lsGeneric data)

This is normally used to make copies of the user data in the new list. If no `copyFunc' is provided, an identity function is used.

lsList lsCopyListList ( lsList   ) 

Copies the contents of a list of lists of ground.

lsList lsCreate ( void   ) 

Create a new list.

Creates a new linked list and returns its handle. The handle is used by all other list manipulation routines and should not be discarded.

lsStatus lsDelAfter ( lsGen  ,
lsGeneric  
)

Delete the item after the current spot.

Removes the item after the current spot. The next call to lsNext will return the item after the deleted item. The next call to lsPrev will be uneffected. This modifies the list. The routine returns LS_BADSTATE if the user tries to call the routine and there is no item after the current spot. This routine returns the userData of the deleted item so it may be freed (if necessary).

lsStatus lsDelBefore ( lsGen  ,
lsGeneric  
)

Delete the item before the current spot.

Removes the item before the current spot. The next call to lsPrev will return the item before the deleted item. The next call to lsNext will be uneffected. This modifies the list. The routine returns LS_BADSTATE if the user tries to call the routine and there is no item before the current spot. This routine returns the userData of the deleted item so it may be freed (if necessary).

lsStatus lsDelBegin ( lsList  ,
lsGeneric  
)

Delete first item of a list.

This routine deletes the first item of a list. The user data associated with the item is returned so the caller may dispose of it. Returns LS_NOMORE if there is no item to delete.

lsStatus lsDelEnd ( lsList  ,
lsGeneric  
)

Delete last item of a list.

This routine deletes the last item of a list. The user data associated with the item is returned so the caller may dispose of it. Returns LS_NOMORE if there is nothing to delete.

lsStatus lsDestroy ( lsList  ,
void(*)(lsGeneric  
)

Delete a previously created list.

Frees all resources associated with the specified list. It frees memory associated with all elements of the list and then deletes the list. User data is released by calling 'delFunc' with the pointer as the argument. Accessing a list after its destruction is a no-no.

lsStatus lsDestroyListList ( lsList   ) 

Delete a previously created list of lists of ground.

lsGen lsEnd ( lsList   ) 

Begin generation at end of list.

This routine defines a generator which is used to step through each item of a list. The generator is initialized to the end of the list.

lsGeneric lsFetchHandle ( lsHandle   ) 

Returns data associated with handle.

This routine returns the user data of the item associated with `itemHandle'.

lsStatus lsFinish ( lsGen   ) 

End generation of items in a list.

Marks the completion of a generation of list items.

This routine should be called after calls to lsNext to free resources used by the generator. This rule applies even if all items of a list are generated by lsNext.

lsStatus lsFirstItem ( lsList  ,
lsGeneric ,
lsHandle  
)

Gets the first item of a list.

Returns the first item in the list. If the list is empty, it returns LS_NOMORE. Otherwise, it returns LS_OK. If 'itemHandle' is non-zero, it will be filled with a handle which may be used to generate a generator.

lsStatus lsForeach ( lsList  list,
lsStatus(*)(lsGeneric, lsGeneric userFunc,
lsGeneric  arg 
)

Calls given function to all element of the list.

This routine generates all items in `list' from the first item to the last calling `userFunc' for each item.

The function should have the following form: lsStatus userFunc(lsGeneric data, lsGeneric arg)

`data' will be the user data associated with the item generated. `arg' will be the same pointer provided to lsForeach. The routine should return LS_OK to continue the generation, LS_STOP to stop generating items, and LS_DELETE to delete the item from the list. If the generation was stopped prematurely, the routine will return LS_STOP. If the user provided function does not return an appropriate value, the routine will return LS_BADPARAM.

lsGen lsGenHandle ( lsHandle  ,
lsGeneric ,
int   
)

Produces a generator given a handle.

This routine produces a generator given a handle. Handles are produced whenever an item is added to a list. The generator produced by this routine may be used when calling any of the standard generation routines.

NOTE: the generator should be freed using lsFinish. The 'option' parameter determines whether the generator spot is before or after the handle item.

lsStatus lsInAfter ( lsGen  ,
lsGeneric  ,
lsHandle  
)

Insert an item after the most recently generated by lsNext.

Inserts an element AFTER the current spot. The next item generated by lsNext will be the new element. The next item generated by lsPrev is unchanged. This modifies the list. 'itemHandle' may be used at a later time to generate a generation handle without searching through the list to find the item.

lsStatus lsInBefore ( lsGen  ,
lsGeneric  ,
lsHandle  
)

Insert an item before the most recently generated by lsNext.

Inserts an element BEFORE the current spot. The item generated by lsNext will be unchanged; the inserted item will be generated by lsPrev. This modifies the list. 'itemHandle' may be used at a later time to produce a generation handle without generating through the list.

void lsJoin ( lsList  ,
lsList  ,
LS_PFLSG   
)

Append second list to first list.

lsStatus lsLastItem ( lsList  ,
lsGeneric ,
lsHandle  
)

Gets the last item of a list.

Returns the last item of a list. If the list is empty, the routine returns LS_NOMORE. Otherwise, 'data' will be set to the last item and the routine will return LS_OK. If 'itemHandle' is non-zero, it will be filled with a handle which can be used to generate a generator postioned at this item.

int lsLength ( lsList   ) 

Returns the length of the list.

Returns the length of the list. The list must have been already created using lsCreate or lsSingleton.

lsStatus lsNewBegin ( lsList  ,
lsGeneric  ,
lsHandle  
)

Add item to start of list.

Adds a new item to the start of a previously created linked list. If 'itemHandle' is non-zero, it will be filled with a handle which can be used to generate a generator positioned at the item without generating through the list.

lsStatus lsNewEnd ( lsList  ,
lsGeneric  ,
lsHandle  
)

Add item to end of list.

Adds a new item to the end of a previously created linked list. This routine appends the item in constant time and can be used freely without guilt.

lsStatus lsNext ( lsGen  ,
lsGeneric ,
lsHandle  
)

Generate next item in sequence.

Generates the item after the item previously generated by lsNext or lsPrev. It returns a pointer to the user data structure in 'data'. 'itemHandle' may be used to get a generation handle without generating through the list to find the item. If there are no more elements to generate, the routine returns LS_NOMORE (normally it returns LS_OK).

lsNext DOES NOT automatically clean up after all elements have been generated. lsFinish must be called explicitly to do this.

See also:
lsFinish
lsStatus lsPrev ( lsGen  ,
lsGeneric ,
lsHandle  
)

Generate previous item in sequence.

Generates the item before the item previously generated by lsNext or lsPrev. It returns a pointer to the user data structure in 'data'. 'itemHandle' may be used to get a generation handle without generating through the list to find the item. If there are no more elements to generate, the routine returns LS_NOMORE (normally it returns LS_OK).

lsPrev DOES NOT automatically clean up after all elements have been generated. lsFinish must be called explicitly to do this.

See also:
lsFinish
lsList lsQueryHandle ( lsHandle   ) 

Returns the list of a handle.

This routine returns the associated list of the specified handle. Returns 0 if there were problems.

lsStatus lsRemoveItem ( lsHandle  ,
lsGeneric  
)

Removes item associated with handle from list.

This routine removes the item associated with `handle' from its list and returns the user data associated with the item for reclaimation purposes. Note this modifies the list that originally contained `item'.

lsList lsSingleton ( lsGeneric  ,
lsHandle  
)

Create a new list containing one element.

Create a new linked list containing one element and return its handle. If 'itemHandle' is non-zero, it will be filled with a handle which can be used to generate a generator positioned at the item without generating through the list.

lsStatus lsSort ( lsList  ,
int(*)(char *, char *)  compare 
)

Sorts a list.

This routine sorts `list' using `compare' as the comparison function between items in the list. `compare' has the following form: int compare(lsGeneric item1, lsGeneric item2)

The routine should return -1 if item1 is less than item2, 0 if they are equal, and 1 if item1 is greater than item2.

The routine uses a generic merge sort written by Rick Rudell.

lsGen lsStart ( lsList   ) 

Begin generation of items in a list.

This routine defines a generator which is used to step through each item of the list. It returns a generator handle which should be used when calling lsNext, lsPrev, lsInBefore, lsInAfter, lsDelete, or lsFinish.

lsStatus lsUniq ( lsList  ,
int(*)(char *, char *)  compare,
void(*)(lsGeneric delFunc 
)

Removes duplicates from a sorted list.

This routine takes a sorted list and removes all duplicates from it. `compare' has the following form:

int compare(lsGeneric item1, lsGeneric item2)

The routine should return -1 if item1 is less than item2, 0 if they are equal, and 1 if item1 is greater than item2. `delFunc' will be called with a pointer to a user data item for each duplicate destroyed. `delFunc' can be zero if no clean up is required.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 14 Oct 2015 for NuSMV Developers Manual by  doxygen 1.6.1