This project has retired. For details please refer to its Attic page.
Clownfish::Vector – C API Documentation
Apache Lucy™

Clownfish::Vector

parcel Clownfish
class variable CFISH_VECTOR
struct symbol cfish_Vector
class nickname cfish_Vec
header file Clownfish/Vector.h

Name

Clownfish::Vector – Variable-sized array.

Functions

new
cfish_Vector* // incremented
cfish_Vec_new(
    size_t capacity
);

Return a new Vector.

capacity

Initial number of elements that the object will be able to hold before reallocation.

init
cfish_Vector*
cfish_Vec_init(
    cfish_Vector *self,
    size_t capacity
);

Initialize a Vector.

capacity

Initial number of elements that the object will be able to hold before reallocation.

Methods

Push
void
cfish_Vec_Push(
    cfish_Vector *self,
    cfish_Obj *element // decremented
);

Push an item onto the end of a Vector.

Push_All
void
cfish_Vec_Push_All(
    cfish_Vector *self,
    cfish_Vector *other
);

Push all the elements of another Vector onto the end of this one.

Pop
cfish_Obj* // incremented
cfish_Vec_Pop(
    cfish_Vector *self
);

Pop an item off of the end of a Vector.

Returns: the element or NULL if the Vector is empty.

Insert
void
cfish_Vec_Insert(
    cfish_Vector *self,
    size_t tick,
    cfish_Obj *element // decremented
);

Insert an element at tick moving the following elements.

Insert_All
void
cfish_Vec_Insert_All(
    cfish_Vector *self,
    size_t tick,
    cfish_Vector *other
);

Inserts elements from other vector at tick moving the following elements.

Fetch
cfish_Obj*
cfish_Vec_Fetch(
    cfish_Vector *self,
    size_t tick
);

Fetch the element at tick.

Returns: the element or NULL if tick is out of bounds.

Store
void
cfish_Vec_Store(
    cfish_Vector *self,
    size_t tick,
    cfish_Obj *elem // decremented
);

Store an element at index tick, possibly displacing an existing element.

Delete
cfish_Obj* // incremented
cfish_Vec_Delete(
    cfish_Vector *self,
    size_t tick
);

Replace an element in the Vector with NULL and return it.

Returns: the element stored at tick or NULL if tick is out of bounds.

Excise
void
cfish_Vec_Excise(
    cfish_Vector *self,
    size_t offset,
    size_t length
);

Remove length elements from the Vector, starting at offset. Move elements over to fill in the gap.

Clone
cfish_Vector* // incremented
cfish_Vec_Clone(
    cfish_Vector *self
);

Clone the Vector but merely increment the refcounts of its elements rather than clone them.

Sort
void
cfish_Vec_Sort(
    cfish_Vector *self
);

Sort the Vector. Sort order is guaranteed to be stable: the relative order of elements which compare as equal will not change.

Resize
void
cfish_Vec_Resize(
    cfish_Vector *self,
    size_t size
);

Set the size for the Vector. If the new size is larger than the current size, grow the object to accommodate NULL elements; if smaller than the current size, decrement and discard truncated elements.

Clear
void
cfish_Vec_Clear(
    cfish_Vector *self
);

Empty the Vector.

Get_Size
size_t
cfish_Vec_Get_Size(
    cfish_Vector *self
);

Return the size of the Vector.

Slice
cfish_Vector* // incremented
cfish_Vec_Slice(
    cfish_Vector *self,
    size_t offset,
    size_t length
);

Return a slice of the Vector consisting of elements from a contiguous range. If the specified range is out of bounds, return a slice with fewer elements – potentially none.

offset

The index of the element to start at.

length

The maximum number of elements to slice.

Equals
bool
cfish_Vec_Equals(
    cfish_Vector *self,
    cfish_Obj *other
);

Equality test.

Returns: true if other is a Vector with the same values as self. Values are compared using their respective Equals methods.

Inheritance

Clownfish::Vector is a Clownfish::Obj.