Olist Struct Reference

Public interface for a Olist class. More...

#include <Olist.h>

Related Functions

(Note that these are not member functions.)



void Olist_append (Olist_ptr self, void *element)
 Adds at the end of a list a new element.
void Olist_clean (Olist_ptr self)
 Removes all the elements of the list, i.e. makes the list empty.
void Olist_concat (Olist_ptr self, Olist_ptr other)
 Adds all the elements of 'other' ath the end of 'self'.
boolean Olist_contains (const Olist_ptr self, const void *element)
 Returns true iff the list contains the given element.
Olist_ptr Olist_copy (Olist_ptr self)
 Creates a copy of a given list.
Olist_ptr Olist_copy_reversed (Olist_ptr self)
 Creates a copy of a given list with the order of elements reversed.
Olist_ptr Olist_copy_without_element (Olist_ptr self, void *element)
 Creates a copy of a given list with all its elements except the provided one.
Olist_ptr Olist_create (void)
 Creates an instance of a One-directional List.
Oiter Olist_delete (Olist_ptr self, Oiter iter, void **element)
 Removes an element pointed by an iterator from a list.
void * Olist_delete_first (Olist_ptr self)
 Removes a first element of a list.
void Olist_destroy (Olist_ptr self)
 Destroys a list instance.
Oiter Olist_end (Olist_ptr self)
 Returns an iterator pointing past the last element of the list.
Oiter Olist_first (Olist_ptr self)
 Returns an iterator pointing to a first element of a list.
int Olist_get_size (const Olist_ptr self)
 Returns the size of a list.
Oiter Olist_insert_after (Olist_ptr self, Oiter iter, void *element)
 Insert a new element into the list "self" directly after an element pointed by "iter".
Oiter Olist_insert_before (Olist_ptr self, Oiter iter, void *element)
 Insert a new element into the list "self" directly before an element pointed by "iter".
boolean Olist_is_empty (Olist_ptr self)
 Returns true iff the list is empty.
boolean Olist_iter_is_first (Olist_ptr self, Oiter iter)
 Returns true if iter corresponds to the first iter.
boolean Olist_iter_is_last (Olist_ptr self, Oiter iter)
 Returns true if iter corresponds to the last element.
Oiter Olist_last (Olist_ptr self)
 Returns an iterator pointing the last element of the list.
void Olist_map (Olist_ptr self, void(*func)(void *elem))
 Functional programming map.
void Olist_move (Olist_ptr self, Olist_ptr to_list, Oiter iter_to)
 Moves the content from one list to another.
void Olist_move_all (Olist_ptr self, Olist_ptr to_list)
 Moves the content from one list to another.
void Olist_prepend (Olist_ptr self, void *element)
 Adds at the beginning of a list a new element.
void Olist_print_node (Olist_ptr self, MasterPrinter_ptr printer, FILE *output)
 Prints the elements of the list using print_node and putting string ", " between elements.
boolean Olist_remove (Olist_ptr self, const void *element)
 Tries to remove all the occurrences of the specified element from the list, returns true if an element was removed, false otherwise.
void Olist_reverse (Olist_ptr self)
 Reverse the order of elements in the list.
void Olist_sort (Olist_ptr self, int(*cmp)(void *el1, void *el2, void *extra), void *extra)
 Sorts the list in place.

Detailed Description

Public interface for a Olist class.

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

Implementation of Olist class


Friends And Related Function Documentation

void Olist_append ( Olist_ptr  self,
void *  element 
) [related]

Adds at the end of a list a new element.

See also:
Olist_prepend
void Olist_clean ( Olist_ptr  self  )  [related]

Removes all the elements of the list, i.e. makes the list empty.

After this function call, Olist_is_empty(self) always returns true.

Note: all existing iterators pointing to the elements of the list becomes invalid.

See also:
Olist_copy_reversed
void Olist_concat ( Olist_ptr  self,
Olist_ptr  other 
) [related]

Adds all the elements of 'other' ath the end of 'self'.

Linear in the size of 'other'

See also:
Olist_append
boolean Olist_contains ( const Olist_ptr  self,
const void *  element 
) [related]

Returns true iff the list contains the given element.

Olist_ptr Olist_copy ( Olist_ptr  self  )  [related]

Creates a copy of a given list.

Note: input list does not change

See also:
Olist_copy_reversed
Olist_ptr Olist_copy_reversed ( Olist_ptr  self  )  [related]

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

Note: input list does not change

See also:
Olist_copy
Olist_ptr Olist_copy_without_element ( Olist_ptr  self,
void *  element 
) [related]

Creates a copy of a given list with all its elements except the provided one.

Note: input list does not change

See also:
Olist_copy
Olist_ptr Olist_create ( void   )  [related]

Creates an instance of a One-directional List.

Oiter Olist_delete ( Olist_ptr  self,
Oiter  iter,
void **  element 
) [related]

Removes an element pointed by an iterator from a list.

Precondition: iter must point to elements of list "self" and NOT the past the last element of the list.

The element being removed is returned in argument *element (only if element != NULL).

Returns an iterator pointing to the element after removed one.

NOTE: all iterators already pointing to the next element will become invalid. Any operations on them are prohibited. ADVICE: do not use several iterators over the same list if deletion operation is possible.

NOTE: if the deletion is used inside an OLIST_FOREACH macro cycle it must be considered that the next element will not be the one after the current deleted element, but the next of it.

void * Olist_delete_first ( Olist_ptr  self  )  [related]

Removes a first element of a list.

The removed element is returned. Precondition: the list must not be empty.

NOTE: all iterators already pointing to the element next to the first one will become invalid. Any operations on them are prohibited. ADVICE: do not use several iterators over the same list if deletion operation is possible.

See also:
Olist_append, Olist_prepend
void Olist_destroy ( Olist_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.

Oiter Olist_end ( Olist_ptr  self  )  [related]

Returns an iterator pointing past the last element of the list.

Function Oiter_is_end will always return true on the result of this function. NOTE: there is no need to free the iterator after using it. NOTE: it is allowed to assign one iterator to another one. NOTE: deletion the elements of the list may make the iterator invalid (see corresponding delete functions).

See also:
Oiter_is_end, Oiter_next, Oiter_element
Oiter Olist_first ( Olist_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 Oiter_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. NOTE: deletion the elements of the list may make the iterator invalid (see corresponding delete functions).

See also:
Oiter_is_end, Oiter_next, Oiter_element, Olist_end
int Olist_get_size ( const Olist_ptr  self  )  [related]

Returns the size of a list.

Oiter Olist_insert_after ( Olist_ptr  self,
Oiter  iter,
void *  element 
) [related]

Insert a new element into the list "self" directly after an element pointed by "iter".

Precondition: iter must point to elements of list "self" and NOT past the last element of the list. If iter is not an iterator of list self there will be problems with memory which are usually very difficult to debug.

NOTE: after the function call iterators pointing to the element after iter will now point to the newly inserted element. All other existing iterators (including iter) will point to the same element as before.

Returns an iterator pointing to the newly inserted element.

Oiter Olist_insert_before ( Olist_ptr  self,
Oiter  iter,
void *  element 
) [related]

Insert a new element into the list "self" directly before an element pointed by "iter".

Precondition: iter must point to elements of list "self" or past the last element of the list.

If the iterator points past the last element of a list then this function is equivalent to calling Olist_append(self, element).

NOTE: All existing iterators equal to "iter" (and iter itself) after insertion will point to the newly created element. All other iterators remain intact.

Returns an iterator pointing to the newly inserted element.

boolean Olist_is_empty ( Olist_ptr  self  )  [related]

Returns true iff the list is empty.

boolean Olist_iter_is_first ( Olist_ptr  self,
Oiter  iter 
) [related]

Returns true if iter corresponds to the first iter.

See also:
Oiter_is_end, Oiter_next, Oiter_element
boolean Olist_iter_is_last ( Olist_ptr  self,
Oiter  iter 
) [related]

Returns true if iter corresponds to the last element.

See also:
Oiter_is_end, Oiter_next, Oiter_element
Oiter Olist_last ( Olist_ptr  self  )  [related]

Returns an iterator pointing the last element of the list.

Function Oiter_is_end will always return true on the result of this function. NOTE: there is no need to free the iterator after using it. NOTE: it is allowed to assign one iterator to another one. NOTE: deletion the elements of the list may make the iterator invalid (see corresponding delete functions).

See also:
Oiter_is_end, Oiter_next, Oiter_element
void Olist_map ( Olist_ptr  self,
void(*)(void *elem)  func 
) [related]

Functional programming map.

Call func over each element of the list. Very useful for example for freeing the elements

void Olist_move ( Olist_ptr  self,
Olist_ptr  to_list,
Oiter  iter_to 
) [related]

Moves the content from one list to another.

The content is moved from "self" to "to_list" and placed before iterator iter_to.

Note: all existing iterators pointing to the elements of the lists may become invalid.

Precondition: iter_to has to be an iterator of list 'to_list' or Oiter_is_end(iter_to) has to be return true.

See also:
Olist_copy_reversed
void Olist_move_all ( Olist_ptr  self,
Olist_ptr  to_list 
) [related]

Moves the content from one list to another.

This function is similar to Olist_move with iter_to set up to point past the last element. Note: all existing iterators pointing to the elements of the list may become invalid.

See also:
Olist_move
void Olist_prepend ( Olist_ptr  self,
void *  element 
) [related]

Adds at the beginning of a list a new element.

See also:
Olist_append
void Olist_print_node ( Olist_ptr  self,
MasterPrinter_ptr  printer,
FILE *  output 
) [related]

Prints the elements of the list using print_node and putting string ", " between elements.

Precondition: all elements of the list have to be node_ptr.

boolean Olist_remove ( Olist_ptr  self,
const void *  element 
) [related]

Tries to remove all the occurrences of the specified element from the list, returns true if an element was removed, false otherwise.

void Olist_reverse ( Olist_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.

See also:
Olist_copy_reversed
void Olist_sort ( Olist_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


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