Collaboration diagram for Vectors:
|
Data Structures | |
| struct | vector_t |
| struct | vector_fns_t |
Functions | |
| static void | vector_init_with_length (void *ptr, int length) |
| static void | vector_init (void *ptr, muse_cell args) |
| static void | vector_mark (void *ptr) |
| static void | vector_destroy (void *ptr) |
| static void | vector_write (void *ptr, void *port) |
| Writes out the vector to the given port in such a way that the expression written out is converted to a vector by a trusted read operation. | |
| muse_cell | fn_vector (muse_env *env, vector_t *v, muse_cell args) |
| The function that implements vector slot access. | |
| static muse_cell | vector_size (void *self) |
| static void | vector_resize (vector_t *self, int new_size) |
| static void | vector_merge_one (vector_t *v, int i, muse_cell new_value, muse_cell reduction_fn) |
| static void | vector_trim (vector_t *v) |
| static muse_cell | vector_map (void *self, muse_cell fn) |
| static muse_cell | vector_join (void *self, muse_cell objlist, muse_cell reduction_fn) |
| static muse_cell | vector_collect (void *self, muse_cell predicate, muse_cell mapper, muse_cell reduction_fn) |
| static muse_cell | vector_reduce (void *self, muse_cell reduction_fn, muse_cell initial) |
| static void * | vector_view (int id) |
| muse_cell | fn_mk_vector (muse_env *env, void *context, muse_cell args) |
| (mk-vector N). | |
| muse_cell | fn_vector_from_args (muse_env *env, void *context, muse_cell args) |
| (vector a1 a2 a3 --- aN). | |
| muse_cell | fn_vector_p (muse_env *env, void *context, muse_cell args) |
| (vector? fv). | |
| muse_cell | fn_vector_length (muse_env *env, void *context, muse_cell args) |
| (vector-length v). | |
| muse_cell | fn_list_to_vector (muse_env *env, void *context, muse_cell args) |
| (list->vector ls). | |
| muse_cell | fn_vector_to_list (muse_env *env, void *context, muse_cell args) |
| (vector->list fv [from count step]). | |
| void | muse_define_builtin_type_vector () |
| muse_cell | muse_mk_vector (int length) |
| Creates a new vector object that has enough slots allocated to hold the given number of objects. | |
| int | muse_vector_length (muse_cell vec) |
| Returns the number of slots the vector has. | |
| muse_cell | muse_vector_get (muse_cell vec, int index) |
| Returns the value occupying the slot at the given 0-based index. | |
| muse_cell | muse_vector_put (muse_cell vec, int index, muse_cell value) |
| Replaces the value in the slot at the given index with the new value. | |
Variables | |
| static muse_monad_view_t | g_vector_monad_view |
| static muse_functional_object_type_t | g_vector_type |
| static struct vector_fns_t | g_vector_fns [] |
A vector can be used like a function. When given one argument which should be an index, it'll return the vaue of the slot at that index. When given two arguments where the first argument is an index, it sets the slot at the given index to the value determined by the second argument.
Examples -
(define vec (mk-vector 5))
(print (vector-length vec))
> 5
(vec 3 'three)
(vec 0 'zero)
(vec 1 'one)
(vec 2 'two)
(vec 4 'four)
(print (vec 2))
> two
(print (vector->list vec))
> (zero one two three four)
(print (vector->list vec 3 2))
> (three four)
| static void vector_init_with_length | ( | void * | ptr, | |
| int | length | |||
| ) | [static] |
| static void vector_init | ( | void * | ptr, | |
| muse_cell | args | |||
| ) | [static] |
| static void vector_mark | ( | void * | ptr | ) | [static] |
| static void vector_destroy | ( | void * | ptr | ) | [static] |
| static void vector_write | ( | void * | ptr, | |
| void * | port | |||
| ) | [static] |
Writes out the vector to the given port in such a way that the expression written out is converted to a vector by a trusted read operation.
The function that implements vector slot access.
| static muse_cell vector_size | ( | void * | self | ) | [static] |
| static void vector_resize | ( | vector_t * | self, | |
| int | new_size | |||
| ) | [static] |
| static void vector_merge_one | ( | vector_t * | v, | |
| int | i, | |||
| muse_cell | new_value, | |||
| muse_cell | reduction_fn | |||
| ) | [static] |
| static void vector_trim | ( | vector_t * | v | ) | [static] |
| static muse_cell vector_collect | ( | void * | self, | |
| muse_cell | predicate, | |||
| muse_cell | mapper, | |||
| muse_cell | reduction_fn | |||
| ) | [static] |
| static void* vector_view | ( | int | id | ) | [static] |
(mk-vector N).
Creates a new vector of length N. All slots in the vector are initially NIL. The returned object is a nativefn (functional object). If vec is the returned object, then
(vec i)
i and(vec i val)
i to val and returns val.
(vector a1 a2 a3 --- aN).
Makes an N-length vector from the arguments with the arguments as the initial values. Useful and compact for small vectors.
(vector? fv).
Returns fv if it is a functional vector. Returns () if it isn't.
(vector-length v).
Evaluates to the length of the given functional vector.
(list->vector ls).
Converts the given list into a vector and returns the vector.
(vector->list fv [from count step]).
Given a functional vector, it returns a list of elements of the vector. If no index range is given, the entire vector is converted into a list. If an index range or step is given, the elements in the range with the given step are converted. The conversion will start with index i and end with index j-1, in steps of step.
| void muse_define_builtin_type_vector | ( | ) |
| muse_cell muse_mk_vector | ( | int | length | ) |
Creates a new vector object that has enough slots allocated to hold the given number of objects.
All slots are initialized to MUSE_NIL.
| int muse_vector_length | ( | muse_cell | vec | ) |
Returns the number of slots the vector has.
Returns the value occupying the slot at the given 0-based index.
Replaces the value in the slot at the given index with the new value.
muse_monad_view_t g_vector_monad_view [static] |
Initial value:
Initial value:
{
'muSE',
'vect',
sizeof(vector_t),
(muse_nativefn_t)fn_vector,
vector_view,
vector_init,
vector_mark,
vector_destroy,
vector_write
}
struct vector_fns_t g_vector_fns[] [static] |
1.4.7