cu/ptr_seq.h: Pointer Sequence Objects
[Data Sequences]

Data Structures

struct  cu_ptr_source
struct  cu_ptr_sink
struct  cu_ptr_junction
struct  cu_ptr_sinktor
struct  cu_ptr_junctor
struct  cu_ptr_array_source

Basic Adaptors and Implementations



struct cu_ptr_source cuP_empty_ptr_source
struct cu_ptr_sink cuP_empty_ptr_sink
struct cu_ptr_junction cuP_empty_ptr_junction
cu_ptr_junction_t cu_ptr_junction_from_source_sink (cu_ptr_source_t source, cu_ptr_sink_t sink)
cu_ptr_junctor_t cu_ptr_junctor_from_source_sinktor (cu_ptr_source_t source, cu_ptr_sinktor_t sinktor)
void cu_ptr_array_source_init (cu_ptr_array_source_t src, void **begin, void **end)
cu_ptr_source_t cu_ptr_source_from_array (void **begin, void **end)
cu_ptr_source_t cu_empty_ptr_source ()
cu_ptr_sink_t cu_empty_ptr_sink ()
cu_ptr_junction_t cu_empty_ptr_junction ()
cu_ptr_junctor_t cu_empty_ptr_junctor (void *result)

API



void cu_ptr_source_init (cu_ptr_source_t source, void *(*get)(cu_ptr_source_t))
void * cu_ptr_source_get (cu_ptr_source_t source)
void cu_ptr_sink_init (cu_ptr_sink_t sink, void(*put)(cu_ptr_sink_t, void *elt))
void cu_ptr_sink_put (cu_ptr_sink_t sink, void *elt)
void cu_ptr_junction_init (cu_ptr_junction_t junction, void *(*get)(cu_ptr_source_t), void(*put)(cu_ptr_sink_t, void *))
void * cu_ptr_junction_get (cu_ptr_junction_t junction)
void cu_ptr_junction_put (cu_ptr_junction_t junction, void *elt)
cu_ptr_source_t cu_ptr_junction_source (cu_ptr_junction_t junction)
cu_ptr_sink_t cu_ptr_junction_sink (cu_ptr_junction_t junction)
void cu_ptr_sinktor_init (cu_ptr_sinktor_t sinktor, void(*put)(cu_ptr_sink_t, void *), void *(*finish)(cu_ptr_sinktor_t sinktor))
void cu_ptr_sinktor_put (cu_ptr_sinktor_t sinktor, void *elt)
void * cu_ptr_sinktor_finish (cu_ptr_sinktor_t sinktor)
cu_ptr_sink_t cu_ptr_sinktor_sink (cu_ptr_sinktor_t sinktor)
void cu_ptr_junctor_init (cu_ptr_junctor_t junctor, void *(*get)(cu_ptr_source_t), void(*put)(cu_ptr_sink_t, void *), void *(*finish)(cu_ptr_junctor_t))
void * cu_ptr_junctor_get (cu_ptr_junctor_t junctor)
void cu_ptr_junctor_put (cu_ptr_junctor_t junctor, void *elt)
void * cu_ptr_junctor_finish (cu_ptr_junctor_t junctor)
cu_ptr_junction_t cu_ptr_junctor_junction (cu_ptr_junctor_t junctor)
cu_ptr_source_t cu_ptr_junctor_source (cu_ptr_junctor_t junctor)
cu_ptr_sink_t cu_ptr_junctor_sink (cu_ptr_junctor_t junctor)

Basic Algorithms



size_t cu_ptr_source_count (cu_ptr_source_t source)
cu_bool_t cu_ptr_source_iterA (cu_clop(f, cu_bool_t, void *), cu_ptr_source_t source)
cu_bool_t cu_ptr_source_iterE (cu_clop(f, cu_bool_t, void *), cu_ptr_source_t source)
cu_bool_t cu_ptr_source_bareA (cu_bool_t(*f)(void *), cu_ptr_source_t source)
cu_bool_t cu_ptr_source_bareE (cu_bool_t(*f)(void *), cu_ptr_source_t source)
void cu_ptr_source_iter (cu_clop(f, void, void *), cu_ptr_source_t source)
int cu_ptr_source_compare (cu_clop(f, int, void *, void *), cu_ptr_source_t source0, cu_ptr_source_t source1)
void cu_ptr_source_sink_short (cu_ptr_source_t source, cu_ptr_sink_t sink)
void ** cu_ptr_source_store (cu_ptr_source_t source, size_t array_size, void **array_out)
void cu_ptr_junction_short (cu_ptr_junction_t junction)
void cu_ptr_source_sink_image (cu_clop(f, void *, void *), cu_ptr_source_t source, cu_ptr_sink_t sink)
void cu_ptr_source_sink_image_cfn (void *(*f)(void *), cu_ptr_source_t source, cu_ptr_sink_t sink)
void cu_ptr_junction_image (cu_clop(f, void *, void *), cu_ptr_junction_t junction)
void cu_ptr_junction_image_cfn (void *(*f)(void *), cu_ptr_junction_t junction)
void * cu_ptr_junctor_image (cu_clop(f, void *, void *), cu_ptr_junctor_t junctor)
void * cu_ptr_junctor_image_cfn (void *(*f)(void *), cu_ptr_junctor_t junctor)
void cu_ptr_source_sink_filter (cu_clop(f, cu_bool_t, void *), cu_ptr_source_t source, cu_ptr_sink_t sink)
void cu_ptr_junction_filter (cu_clop(f, cu_bool_t, void *), cu_ptr_junction_t junction)
void * cu_ptr_junctor_filter (cu_clop(f, cu_bool_t, void *), cu_ptr_junctor_t junctor)

Detailed Description

This header defines generic ways of processing sequences of pointers. The structs combine three concepts: sources which provide a sequence of pointers, sinks which consume a sequence of pointers, and construction.

A combination of a source and a sink is here called a junction. It can be used to compute the image of a collection of objects in cases where it is desirable that the transforming function controls the iteration.

A sink can be useful for finishing the construction of a container. A combination of a sink and a constructor is here called a sinktor. Similarly, we the combination of a junction and a constructor will be called a junctor.


Function Documentation

cu_ptr_junction_t cu_empty_ptr_junction (  ) 

A junction with an empty source and an empty sink.

See also:
cu_empty_ptr_source
cu_empty_ptr_sink
cu_ptr_junctor_t cu_empty_ptr_junctor ( void *  result  ) 

A junctor with an empty source and an empty sink, which returns result.

cu_ptr_sink_t cu_empty_ptr_sink (  ) 

A sink which does not accept any items. An attempt to put an item into it is considered a bug and will cause the program to abort.

cu_ptr_source_t cu_empty_ptr_source (  ) 

A source which always returns NULL.

void cu_ptr_array_source_init ( cu_ptr_array_source_t  src,
void **  begin,
void **  end 
)

A source which fetches pointers from [begin, end).

void cu_ptr_junction_filter ( cu_clop(f, cu_bool_t, void *)  ,
cu_ptr_junction_t  junction 
)

Filters from the source to the sink of junction with f by putting only those which f maps to true into the sink. This is equivalent to cu_ptr_source_sink_filter applied to the source and sink parts of junction.

void* cu_ptr_junction_get ( cu_ptr_junction_t  junction  ) 

Returs the next element of the source sequence of the junction.

void cu_ptr_junction_image ( cu_clop(f, void *, void *)  ,
cu_ptr_junction_t  junction 
)

Transforms the remaining elements of the source of junction with f and puts them in order into the sink of junction. This is equivalent to cu_ptr_source_sink_image applied to the source and sink of junction.

void cu_ptr_junction_image_cfn ( void *(*)(void *)  f,
cu_ptr_junction_t  junction 
)

A variant cu_ptr_junction_image accepting a contextfree C function as callback.

void cu_ptr_junction_init ( cu_ptr_junction_t  junction,
void *(*)(cu_ptr_source_t get,
void(*)(cu_ptr_sink_t, void *)  put 
)

Initialises the callbacks of junction.

void cu_ptr_junction_put ( cu_ptr_junction_t  junction,
void *  elt 
)

Puts elt into the sink of the junction.

void cu_ptr_junction_short ( cu_ptr_junction_t  junction  ) 

Transfers the remaining elements of the source of junction to its sink. This is equivalent to cu_ptr_source_sink_short applied to the source and sink of junction.

cu_ptr_sink_t cu_ptr_junction_sink ( cu_ptr_junction_t  junction  ) 

Returns the sink of junction.

cu_ptr_source_t cu_ptr_junction_source ( cu_ptr_junction_t  junction  ) 

Returns the source of junction.

void* cu_ptr_junctor_filter ( cu_clop(f, cu_bool_t, void *)  ,
cu_ptr_junctor_t  junctor 
)

Performs cu_ptr_junction_filter, then returns the result of cu_ptr_junctor_finish.

void* cu_ptr_junctor_finish ( cu_ptr_junctor_t  junctor  ) 

Finishes the construction based to the sink state.

void* cu_ptr_junctor_get ( cu_ptr_junctor_t  junctor  ) 

Returns the next element of the source of the junctor.

void* cu_ptr_junctor_image ( cu_clop(f, void *, void *)  ,
cu_ptr_junctor_t  junctor 
)

Same as cu_ptr_junction_image, but also returns the result of calling cu_ptr_junctor_finish at the end.

void* cu_ptr_junctor_image_cfn ( void *(*)(void *)  f,
cu_ptr_junctor_t  junctor 
)

A variant cu_ptr_junctor_image accepting a contextfree C function as callback.

void cu_ptr_junctor_init ( cu_ptr_junctor_t  junctor,
void *(*)(cu_ptr_source_t get,
void(*)(cu_ptr_sink_t, void *)  put,
void *(*)(cu_ptr_junctor_t finish 
)

Initialises the callbacks of junctor.

cu_ptr_junction_t cu_ptr_junctor_junction ( cu_ptr_junctor_t  junctor  ) 

Returns the junction of junctor.

void cu_ptr_junctor_put ( cu_ptr_junctor_t  junctor,
void *  elt 
)

Puts elt into the sink of the junctor.

cu_ptr_sink_t cu_ptr_junctor_sink ( cu_ptr_junctor_t  junctor  ) 

Returns the sink of junctor.

cu_ptr_source_t cu_ptr_junctor_source ( cu_ptr_junctor_t  junctor  ) 

Returns the source of junctor.

void cu_ptr_sink_init ( cu_ptr_sink_t  sink,
void(*)(cu_ptr_sink_t, void *elt)  put 
)

Initialises the callback of sink.

void cu_ptr_sink_put ( cu_ptr_sink_t  sink,
void *  elt 
)

Puts elt into sink.

void* cu_ptr_sinktor_finish ( cu_ptr_sinktor_t  sinktor  ) 

Finishes the construction based on the sink state.

void cu_ptr_sinktor_init ( cu_ptr_sinktor_t  sinktor,
void(*)(cu_ptr_sink_t, void *)  put,
void *(*)(cu_ptr_sinktor_t sinktor)  finish 
)

Initialises the callbacks of sinktor.

void cu_ptr_sinktor_put ( cu_ptr_sinktor_t  sinktor,
void *  elt 
)

Puts elt into the sink of the sinktor.

cu_ptr_sink_t cu_ptr_sinktor_sink ( cu_ptr_sinktor_t  sinktor  ) 

Returns the sink of sinktor.

int cu_ptr_source_compare ( cu_clop(f, int, void *, void *)  ,
cu_ptr_source_t  source0,
cu_ptr_source_t  source1 
)

Compares the two sources by applying f to each parallel pair of elements drawn from source0 and source1. At the first non-zero return by f, that value is returned. If both sources are emptied, 0 is returned, if only source0 emptied, -1 is returned, and if only source1 is emptied, 1 is returned.

size_t cu_ptr_source_count ( cu_ptr_source_t  source  ) 

Counts the number of remaining elements on source, draining it in the process. Takes time proportional to the count.

cu_ptr_source_t cu_ptr_source_from_array ( void **  begin,
void **  end 
)

A source which fetches pointers from [begin, end).

void* cu_ptr_source_get ( cu_ptr_source_t  source  ) 

Returs the next element of the source sequence, or NULL if there are no more elements.

void cu_ptr_source_init ( cu_ptr_source_t  source,
void *(*)(cu_ptr_source_t get 
)

Initialises the callback of source.

void cu_ptr_source_iter ( cu_clop(f, void, void *)  ,
cu_ptr_source_t  source 
)

Calls f on each element of source.

cu_bool_t cu_ptr_source_iterA ( cu_clop(f, cu_bool_t, void *)  ,
cu_ptr_source_t  source 
)

True iff f maps each remaining element of source to true. Stops after the first failure.

cu_bool_t cu_ptr_source_iterE ( cu_clop(f, cu_bool_t, void *)  ,
cu_ptr_source_t  source 
)

True iff f maps at least one of the remaining elements to true. Stops after the first match.

void cu_ptr_source_sink_filter ( cu_clop(f, cu_bool_t, void *)  ,
cu_ptr_source_t  source,
cu_ptr_sink_t  sink 
)

Filters the elements of source, putting those which f maps to true into sink.

void cu_ptr_source_sink_image ( cu_clop(f, void *, void *)  ,
cu_ptr_source_t  source,
cu_ptr_sink_t  sink 
)

Transforms the remaining elements of source with f and puts them in order into sink.

void cu_ptr_source_sink_image_cfn ( void *(*)(void *)  f,
cu_ptr_source_t  source,
cu_ptr_sink_t  sink 
)

A variant cu_ptr_source_sink_image accepting a contextfree C function as callback.

void cu_ptr_source_sink_short ( cu_ptr_source_t  source,
cu_ptr_sink_t  sink 
)

Transfers the remaining elements in source to sink.

void** cu_ptr_source_store ( cu_ptr_source_t  source,
size_t  array_size,
void **  array_out 
)

Stores up to array_size pointers from source into an array of pointers starting at array_out, and returns a pointer past the last assigned element.

Generated 2009-11-23 for culibs-0.25 using Doxygen. Maintained by Petter Urkedal.