## dzl-ring

dzl-ring

## Functions

#define | dzl_ring_append_val()
#define | dzl_ring_get_index()
DzlRing * | dzl_ring_sized_new ()
guint | dzl_ring_append_vals ()
void | dzl_ring_foreach ()
DzlRing * | dzl_ring_ref ()
void | dzl_ring_unref ()

## Description

## Functions

### dzl_ring_append_val()

    #define dzl_ring_append_val(ring, val) dzl_ring_append_vals(ring, &(val), 1)

Appends a value to the ring buffer. `val` must be a variable as it is referenced to.

#### Parameters

ring | A DzlRing. |
val | A value to append to the DzlRing. |

#### Returns

None.

### dzl_ring_get_index()

    #define             dzl_ring_get_index(ring, type, i)

Retrieves the value at the given index from the DzlRing. The value is cast to `type` . You may retrieve a pointer to the value within the array by using &.

[[ gdouble *v = &dzl_ring_get_index(ring, gdouble, 0); gdouble v = dzl_ring_get_index(ring, gdouble, 0); ]]

#### Parameters

ring | A DzlRing. |
type | The type to extract. |
i | The index within the DzlRing relative to the current position. |

#### Returns

The value at the given index.

### dzl_ring_sized_new ()

    DzlRing *
    dzl_ring_sized_new (guint element_size,
                        guint reserved_size,
                        GDestroyNotify element_destroy);

Creates a new instance of DzlRing with the given number of elements.

#### Parameters

element_size | The size per element. | [in]
reserved_size | The number of elements to allocate. | [in]
element_destroy | Notification called when removing an element. | [in]

#### Returns

A new DzlRing.

### dzl_ring_append_vals ()

    guint
    dzl_ring_append_vals (DzlRing *ring,
                          gconstpointer data,
                          guint len);

Appends `len` values located at `data` .

#### Parameters

ring | A DzlRing. | [in]
data | A pointer to the array of values. | [in]
len | The number of values. | [in]

#### Returns

the index of the first item.

### dzl_ring_foreach ()

    void
    dzl_ring_foreach (DzlRing *ring,
                      GFunc func,
                      gpointer user_data);

Calls `func` for every item in the DzlRing starting from the most recently inserted element to the least recently inserted.

#### Parameters

ring | A DzlRing. | [in]
func | A GFunc to call for each element. | [in][scope call]
user_data | user data for `func` . | [in]

### dzl_ring_ref ()

    DzlRing *
    dzl_ring_ref (DzlRing *ring);

Atomically increments the reference count of `ring` by one.

#### Parameters

ring | A DzlRing. | [in]

#### Returns

The `ring` pointer.

### dzl_ring_unref ()

    void
    dzl_ring_unref (DzlRing *ring);

Atomically decrements the reference count of `ring` by one. When the reference count reaches zero, the structure is freed.

#### Parameters

ring | A DzlRing. | [in]