Slist Struct Reference

Public interface for a Slist (Simple List) class. More...

#include <Slist.h>

Related Functions

(Note that these are not member functions.)



void Slist_append (Slist_ptr self, const Slist_ptr other)
 Appends two lists modifying self.
void Slist_clear (Slist_ptr self)
 Pops all the elements of this list.
boolean Slist_contains (Slist_ptr self, const void *element)
 Checks whether the specified element is in the list or not.
Slist_ptr Slist_copy (Slist_ptr self)
 Creates a copy of a given list.
Slist_ptr Slist_copy_reversed (Slist_ptr self)
 Creates a copy of a given list with the order of elements reversed.
Slist_ptr Slist_create (void)
 Creates an instance of a Simple List.
void Slist_destroy (Slist_ptr self)
 Destroys a list instance.
void Slist_destroy_and_free_elements (Slist_ptr self, Slist_free_function f)
 Destroys the list and every element contained using the specified function.
boolean Slist_equals (const Slist_ptr self, const Slist_ptr other)
 Returns true iff the two lists are equal (contains the same elements in the same order).
Siter Slist_find (Slist_ptr self, const void *element)
 Returns an iterator pointing to the first element equal to the given one.
Siter Slist_first (Slist_ptr self)
 Returns an iterator pointing to a first element of a list.
unsigned int Slist_get_size (Slist_ptr self)
 Returns the size of a list.
boolean Slist_is_empty (Slist_ptr self)
 Returns true iff the list is empty.
void * Slist_pop (Slist_ptr self)
 Removes an element at the beginning of a list.
void Slist_push (Slist_ptr self, void *element)
 Adds at the beginning of a list a new element.
boolean Slist_remove (Slist_ptr self, const void *element)
 Removes all the occurrencies of specified element if present in the list. Returns true if the element was removed, false otherwise.
void Slist_reverse (Slist_ptr self)
 Reverse the order of elements in the list.
void Slist_sort (Slist_ptr self, int(*cmp)(void *el1, void *el2, void *extra), void *extra)
 Sorts the list in place.
void * Slist_top (Slist_ptr self)
 Returns the element at the beginning of a list.

Detailed Description

Public interface for a Slist (Simple List) class.

Author:
Andrei Tchaltsev See Slist.c for the description.

Implementation of Slist class


Friends And Related Function Documentation

void Slist_append ( Slist_ptr  self,
const Slist_ptr  other 
) [related]

Appends two lists modifying self.

self is extended

void Slist_clear ( Slist_ptr  self  )  [related]

Pops all the elements of this list.

boolean Slist_contains ( Slist_ptr  self,
const void *  element 
) [related]

Checks whether the specified element is in the list or not.

See also:
Slist_first, Siter_is_end, Siter_next
Slist_ptr Slist_copy ( Slist_ptr  self  )  [related]

Creates a copy of a given list.

Note: input list does not change

See also:
Slist_copy_reversed
Slist_ptr Slist_copy_reversed ( Slist_ptr  self  )  [related]

Creates a copy of a given list with the order of elements reversed.

Note: input list does not change

See also:
Slist_copy
Slist_ptr Slist_create ( void   )  [related]

Creates an instance of a Simple List.

void Slist_destroy ( Slist_ptr  self  )  [related]

Destroys a list instance.

The memory used by the list will be freed. Note: memory occupied by the elements is not freed! It is the user responsibility.

void Slist_destroy_and_free_elements ( Slist_ptr  self,
Slist_free_function  f 
) [related]

Destroys the list and every element contained using the specified function.

boolean Slist_equals ( const Slist_ptr  self,
const Slist_ptr  other 
) [related]

Returns true iff the two lists are equal (contains the same elements in the same order).

Siter Slist_find ( Slist_ptr  self,
const void *  element 
) [related]

Returns an iterator pointing to the first element equal to the given one.

If there is no such element then on the returned iterator Siter_is_end(iter) will be true.

See also:
Slist_first, Siter_is_end, Siter_next
Siter Slist_first ( Slist_ptr  self  )  [related]

Returns an iterator pointing to a first element of a list.

If the list is empty the iterator will point past the last element of a list (i.e. past the list). This means function Siter_is_end will return true in this case. NOTE: there is no need to free the iterator after using it. NOTE: it is allowed to assign one iterator to another one.

See also:
Siter_is_end, Siter_next, Siter_element
unsigned int Slist_get_size ( Slist_ptr  self  )  [related]

Returns the size of a list.

See also:
Slist_append
boolean Slist_is_empty ( Slist_ptr  self  )  [related]

Returns true iff the list is empty.

void * Slist_pop ( Slist_ptr  self  )  [related]

Removes an element at the beginning of a list.

The removed element is returned. Existing iterators pointing to the first element become invalid after this function call and cannot be used any further.

See also:
Slist_append
void Slist_push ( Slist_ptr  self,
void *  element 
) [related]

Adds at the beginning of a list a new element.

See also:
Slist_append
boolean Slist_remove ( Slist_ptr  self,
const void *  element 
) [related]

Removes all the occurrencies of specified element if present in the list. Returns true if the element was removed, false otherwise.

See also:
Slist_first, Siter_is_end, Siter_next
void Slist_reverse ( Slist_ptr  self  )  [related]

Reverse the order of elements in the list.

Note: all existing iterators pointing to the elements of the list may become invalid. Do not use them after this function call.

See also:
Slist_copy_reversed
void Slist_sort ( Slist_ptr  self,
int(*)(void *el1, void *el2, void *extra)  cmp,
void *  extra 
) [related]

Sorts the list in place.

mergesort is used to sort the list. worst case complexisty O(N log2(N)).

cmp is comparison function returning value v, v < 0, v == 0 or v > 0 extra is a user parameter that is passed to every invocation of cmp

void * Slist_top ( Slist_ptr  self  )  [related]

Returns the element at the beginning of a list.

See also:
Slist_append

The documentation for this struct was generated from the following file:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

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