parcel | Clownfish |
class variable | CFISH_VECTOR |
struct symbol | cfish_Vector |
class nickname | cfish_Vec |
header file | Clownfish/Vector.h |
Clownfish::Vector – Variable-sized array.
cfish_Vector* // incremented
cfish_Vec_new(
size_t capacity
);
Return a new Vector.
Initial number of elements that the object will be able to hold before reallocation.
cfish_Vector*
cfish_Vec_init(
cfish_Vector *self,
size_t capacity
);
Initialize a Vector.
Initial number of elements that the object will be able to hold before reallocation.
void
cfish_Vec_Push(
cfish_Vector *self,
cfish_Obj *element // decremented
);
Push an item onto the end of a Vector.
void
cfish_Vec_Push_All(
cfish_Vector *self,
cfish_Vector *other
);
Push all the elements of another Vector onto the end of this one.
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.
void
cfish_Vec_Insert(
cfish_Vector *self,
size_t tick,
cfish_Obj *element // decremented
);
Insert an element at tick
moving the following elements.
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.
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.
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.
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.
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.
cfish_Vector* // incremented
cfish_Vec_Clone(
cfish_Vector *self
);
Clone the Vector but merely increment the refcounts of its elements rather than clone them.
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.
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.
void
cfish_Vec_Clear(
cfish_Vector *self
);
Empty the Vector.
size_t
cfish_Vec_Get_Size(
cfish_Vector *self
);
Return the size of the Vector.
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.
The index of the element to start at.
The maximum number of elements to slice.
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.
Clownfish::Vector is a Clownfish::Obj.
Copyright © 2010-2015 The Apache Software Foundation, Licensed under the
Apache License, Version 2.0.
Apache Lucy, Lucy, Apache, the Apache feather logo, and the Apache Lucy project logo are trademarks of The
Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their
respective owners.