☰

*ON THIS PAGE*# Extendable arrays with logarithmic access time

**Author(s):** Lena Flood.## Usage and interface

## Documentation on exports

## Documentation on imports

This module has the following direct dependencies:

- The Ciao System »

- PART VI - Data structures and algorithms »

**Extendable arrays with logarithmic access time**

This module implements extendable arrays with logarithmic access time. It has been adapted from shared code written by David Warren and Fernando Pereira.

**Library usage:**`:- use_module(library(arrays)).`**Exports:***Predicates:*`new_array/1`,`is_array/1`,`aref/3`,`arefa/3`,`arefl/3`,`aset/4`,`array_to_list/2`.

PREDICATEnew_array/1

Usage:`new_array(Array)`

returns an empty new array Array.

*The following properties should hold at call time:*

(`term_typing:var/1`)Array is a free variable.

PREDICATEis_array/1

Usage:`is_array(Array)`

Array actually is an array.

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)Array is currently a term which is not a free variable.

PREDICATEaref/3

Usage:`aref(Index,Array,Element)`

unifies Element to Array[Index], or fails if Array[Index] has not been set.

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)Index is currently a term which is not a free variable.

(`term_typing:nonvar/1`)Array is currently a term which is not a free variable.

PREDICATEarefa/3

Usage:`arefa(Index,Array,Element)`

is as `aref/3`, except that it unifies Element with a new array if Array[Index] is undefined. This is useful for multidimensional arrays implemented as arrays of arrays.

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)Index is currently a term which is not a free variable.

(`term_typing:nonvar/1`)Array is currently a term which is not a free variable.

PREDICATEarefl/3

Usage:`arefl(Index,Array,Element)`

is as `aref/3`, except that Element appears as `[]` for undefined cells. Thus, `arefl(_,_,[])` always succeeds no matter what you give in the first or second args.

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)Index is currently a term which is not a free variable.

(`term_typing:nonvar/1`)Array is currently a term which is not a free variable.

PREDICATEaset/4

Usage:`aset(Index,Array,Element,NewArray)`

unifies NewArray with the result of setting Array[Index] to Element.

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)Index is currently a term which is not a free variable.

(`term_typing:nonvar/1`)Array is currently a term which is not a free variable.

(`term_typing:var/1`)NewArray is a free variable.

PREDICATEarray_to_list/2

Usage:`array_to_list(Array,List)`

returns a List of pairs Index-Element of all the elements of Array that have been set.

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)Array is currently a term which is not a free variable.

(`term_typing:var/1`)List is a free variable.

*Packages:*`prelude`,`initial`,`condcomp`,`assertions`,`assertions/assertions_basic`,`isomodes`.

Generated with LPdoc using Ciao