cvx
Loading...
Searching...
No Matches
buffer_iterator.h File Reference

Go to the source code of this file.

Data Structures

struct  cvx_container
 
struct  buffer_iterator
 

Typedefs

typedef struct cvx_container cvx_container
 

Enumerations

enum  cvx_flags {
  CVX_FLAG_OK = 0 , CVX_FLAG_VTAB = 1 , CVX_FLAG_WRONG_TAG = 2 , CVX_FLAG_ALLOC = 3 ,
  CVX_FLAG_EMPTY = 4 , CVX_FLAG_FULL = 5 , CVX_FLAG_RANGE = 6 , CVX_FLAG_NOT_FOUND = 7 ,
  CVX_FLAG_INVALID = 8 , CVX_FLAG_DUPLICATE = 9 , CVX_FLAG_ERROR = 10
}
 buffer_iterator.h More...
 
enum  cvx_heap_order { CVX_MAX_HEAP = 1 , CVX_MIN_HEAP = -1 }
 enum cvx_heap_order More...
 

Functions

struct buffer_iterator bi_start (TVal *buffer, size_t capacity, size_t count)
 
struct buffer_iterator bi_end (TVal *buffer, size_t capacity, size_t count)
 
_Bool bi_at_end (struct buffer_iterator *self)
 
_Bool bi_at_start (struct buffer_iterator *self)
 
void bi_to_end (struct buffer_iterator *self)
 
void bi_to_start (struct buffer_iterator *self)
 
void bi_next (struct buffer_iterator *self)
 
void bi_prev (struct buffer_iterator *self)
 
void bi_go_to (struct buffer_iterator *self)
 
void bi_forward (struct buffer_iterator *self, size_t steps)
 
void bi_backward (struct buffer_iterator *self, size_t steps)
 
size_t bi_index (struct buffer_iterator *self)
 
TVal bi_value (struct buffer_iterator *self)
 

Typedef Documentation

◆ cvx_container

typedef struct cvx_container cvx_container

Enumeration Type Documentation

◆ cvx_flags

enum cvx_flags

buffer_iterator.h

Status

[x] concept [x] v1 [ ] tests [ ] refine [ ] stabilize

The implementation of the buffer iterator can be tuned depending on what the underlying data structure needs.

This is the basic interface: for (struct iterator it = init_iter(&arr); !iter_at_end(&it); iter_next(&it)) { char *key = iter_key(&it); int value = iter_value(&it); ... }

User defined macro options

  • SPARSE(item): a function-like macro that receives and item and checks if this is just a "hole" or an actual item
  • CIRCULAR: if enabled, the pointer wraps around the buffer's capacity

Other macros

  • EMBEDDED: Used by other data structures to automatically implement an iterator. When this is enabled, it changes the input macros and prefixes them all with "IT_".

Status and error flags for the CVX library.

Error Handling

Enumerator
CVX_FLAG_OK 

No errors.

CVX_FLAG_VTAB 

Required vtab function was not provided.

CVX_FLAG_WRONG_TAG 

Tags are checked so you don't pass the wrong struct to a function.

CVX_FLAG_ALLOC 

Allocation failed.

CVX_FLAG_EMPTY 

Operation can not proceed because the container is empty.

CVX_FLAG_FULL 

When a container that doesn't resize is full.

CVX_FLAG_RANGE 

Index out of range.

CVX_FLAG_NOT_FOUND 

Key or value not found.

CVX_FLAG_INVALID 

Invalid argument or operation.

CVX_FLAG_DUPLICATE 

Duplicate key or value.

CVX_FLAG_ERROR 

Generic error, or unknown error.

◆ cvx_heap_order

enum cvx_heap_order

Defines the two possible heaps:

  • Max Heap has the greatest element at the top
  • Min Heap has the smallest element at the top
Enumerator
CVX_MAX_HEAP 
CVX_MIN_HEAP 

Function Documentation

◆ bi_at_end()

_Bool bi_at_end ( struct buffer_iterator self)

◆ bi_at_start()

_Bool bi_at_start ( struct buffer_iterator self)

◆ bi_backward()

void bi_backward ( struct buffer_iterator self,
size_t  steps 
)

◆ bi_end()

struct buffer_iterator bi_end ( TVal *  buffer,
size_t  capacity,
size_t  count 
)

◆ bi_forward()

void bi_forward ( struct buffer_iterator self,
size_t  steps 
)

◆ bi_go_to()

void bi_go_to ( struct buffer_iterator self)

◆ bi_index()

size_t bi_index ( struct buffer_iterator self)

◆ bi_next()

void bi_next ( struct buffer_iterator self)

◆ bi_prev()

void bi_prev ( struct buffer_iterator self)

◆ bi_start()

struct buffer_iterator bi_start ( TVal *  buffer,
size_t  capacity,
size_t  count 
)

◆ bi_to_end()

void bi_to_end ( struct buffer_iterator self)

◆ bi_to_start()

void bi_to_start ( struct buffer_iterator self)

◆ bi_value()

TVal bi_value ( struct buffer_iterator self)