push-new ( vector -- new )
Specialized vectors

Prev:Passing specialized vectors to C functions


Vocabulary
specialized-vectors

Inputs
vectora specialized vector of structs


Outputs
newa new value of the specialized vector's type


Word description
Grows vector, increasing its length by one, and outputs a struct object wrapping the newly allocated storage.

Notes
This word allows struct objects to be streamed into a struct vector efficiently without excessive copying. The typical Factor idiom for pushing a new object onto a vector, when used with struct vectors, will allocate and copy a temporary struct object:
foo <struct> 5 >>a 6 >>b foo-vector{ } clone push

By using push-new, the new struct can be allocated directly from the vector and the intermediate copy can be avoided:
foo-vector{ } clone push-new 5 >>a 6 >>b drop


Definition