« Home » « Learn » « Download » « Github »

logo

Cello High Level C

Methods

resize

void resize(var self, size_t n);

Resize to some size n, perhaps reserving some resource for object self.

Examples

Usage

var x = new(Array, Int);
resize(x, 10000); /* Reserve space in Array */ 
for (size_t i = 0; i < 10000; i++) {
  push(x, $I(i));
}

Usage 2

var x = new(Array, Int, $I(0), $I(1), $I(2));
resize(x, 0); /* Clear Array of items */

Resize


Object can be resized

The Resize class can be implemented by objects which can be resized in some way. Resizing to a larger size than the current may allow for some resource or other to be preallocated or reserved. For example this class is implemented by Array and Table to either remove a number of items quickly or to preallocate memory space if it is known that many items are going to be added at a later date.

Definition

struct Resize {
  void (*resize)(var, size_t);
};

Implementers

  • Array |     Sequential Container
  • List |     Linked List
  • String |     String Object
  • Table |     Hash table
  • Tree |     Balanced Binary Tree
  • Tuple |     Basic Collection

Back