- Now using user defined resizing functions. Surprisingly, this actually
cleaned up the code. Two default resizing functions are supplied-
exponential, which doubles the array size when the number of used elements
is greater than the array size, and halves the array size when the number
of used elements is less the 1/4th the array size (to help prevent
thrashing), and stepping, which adds or subtracts a given step size.
Resizers are applied as optional arguments- generally the default is
exponential. So you can just do:
make len null
to get the exponential resizer, or:
make ~resizer:(step_resizer 10) len null
to get the stepwise resizer, or:
make ~resizer:my_resizer len null
to use your own resizer.
The only places where exponential is not the default resizer is the copy,
map, and mapi functions, which by default uses the resizer of the source
xarray (but can be overridden with a default argument as above, allowing
you to change resizer functions while copying the xarray). The function
invalid_resizer is an internal function which tells me to use the source
- Got rid of the negative index "feature"- people seemed to be mainly
against it, and it cleaned up and simplified the code. This also let me
turn a bunch of let rec's into just let's. Added a last function to
return the last element- the API already had remove_last and append
- The .mli file now has doc comments! Yay! The .ml file still needs to
- Note that Array.append appends two whole arrays, as does List.append.
So I changed the name to append_element, and wrote an append which appends
an xarray. Added a sub function.
- Added a copy function. A set_length function was already in the API
(changed it's name to set_length not set_len). set_length now explicitly
sets the array length to the given length, without calling the resizer.
- Minor enhancements- started using the Array.sub and Array.copy functions
- Length is the length of the actual underlying storage array, used is the
number of elements in that array actually being used. I've decided on
that nomenclature, and started sticking by it.
- Sort functions, etc. still need to be written.