Next: , Up: Data Structures   [Contents][Index]

5.6.1 Array Lists

The (chickadee data array-list) module provides an array/vector that dynamically expands to hold all of the data that is added to it. It is named after the ArrayList class in Java.

In addition to being used as a dynamic vector, it can also be used as a stack via the array-list-push! and array-list-pop! procedures.

Procedure: make-array-list [initial-capacity]

Return a new empty array list with an initial capacity of initial-capacity, or 32 by default.

Procedure: array-list items ...

Return a new array list with items in it.

Procedure: array-list? obj

Return #t if obj is an array list.

Procedure: array-list-empty? array-list

Return #t if array-list is empty.

Procedure: array-list-size array-list

Return the current size of array-list.

Procedure: array-list-ref array-list i

Return the item in array-list at index i.

Procedure: array-list-set! array-list i value

Set the value in array-list at index i to value.

Procedure: array-list-push! array-list item

Append item to array-list.

Procedure: array-list-pop! array-list

Remove and return the last object in array-list.

Procedure: array-list-delete! array-list item [#:equal? equal?] [#:fast? #f]

Delete item from array-list. Use equal? as the equivalence predicate, which defaults to Guile’s equal? procedure. By default, deletion preserves the order of the array, but takes linear time in the worst case. If fast? is #t then item will deleted in constant time, but order is not preserved.

Procedure: array-list-clear! array-list

Remove all items from array-list.

Procedure: array-list-for-each proc array-list

Apply PROC with each item in array-list.

Procedure: array-list-fold proc init array-list

Apply proc to all items in array-list to build a result and return that result. init is the initial result. If there are no objects in the vicinity of rect, just init is returned.

Next: , Up: Data Structures   [Contents][Index]