Resizable sequence implementation
Factor handbook > The language > Collections

Prev:String buffers
Next:Associative mapping operations

Resizable sequences are implemented by having a wrapper object hold a reference to an underlying sequence, together with a fill pointer indicating how many elements of the underlying sequence are occupied. When the fill pointer exceeds the underlying sequence capacity, the underlying sequence grows.

There is a resizable sequence mixin:

This mixin implements the sequence protocol by assuming the object has two specific slots:
length - the fill pointer (number of occupied elements in the underlying storage)
underlying - the underlying storage

The underlying sequence must implement a generic word:
resize ( n seq -- newseq )

Vectors and String buffers are implemented using the resizable sequence facility.