YAP 7.1.0
Arrays

Detailed Description

Modules

 Implementation Notes
 This file works together with pl/arrays.yap and arrays.h.
 

Class Documentation

◆ array_element/3

class array_element/3

array_element(+ Name, + Index, ? Element)

Unify Element with Name[ Index] It works for both static and dynamic arrays, but it is read-only for static arrays, while it can be used to unify with an element of a dynamic array

◆ create_array/2

class create_array/2

create_array(?Name, + Size)

Allocate a vector of Prolog cells of size SiZe and with handle Name

◆ static_array/3

class static_array/3

static_array(+ Name, + Size, + Type)

Create a new static array with name Name Note that the Name must be an atom (named array) The Size must evaluate to an integer The Type must be bound to one of types mentioned previously

Values are initialised to 0

◆ static_array_properties/3

class static_array_properties/3

static_array_properties(+Name,+Size,+Type)

static_array_properties(? Name, ? Size, ? Type)

Succeed if Name has a static array associated Moreover, the second arguent must unify with the Size and the third with the type

Show the properties size and type of a static array with name Name Can also be used to enumerate all current static arrays

This built-in will silently fail if the there is no static array with that name

◆ reset_static_array/1

class reset_static_array/1

reset_static_array(+ Name)

Reset static array with name Name to its initial value

◆ close_static_array/1

class close_static_array/1

close_static_array(+ Name)

Close an existing static array of name Name The Name must be an atom (named array) Space for the array will be recovered and further accesses to the array will return an error

◆ mmapped_array/4

class mmapped_array/4

mmapped_array(+ Name, + Size, + Type, + File)

Similar to static_array/3 , but the array is memory mapped to file File This means that the array is initialized from the file, and that any changes to the array will also be stored in the file

This built-in is only available in operating systems that support the system call mmap Moreover, mmapped arrays do not store generic terms (type term)

◆ update_array/3

class update_array/3

update_array(+ Name, + Index, ? Value)

Attribute value Value to Name[ Index] Type restrictions must be respected for static arrays This operation is available for dynamic arrays if MULTI_ASSIGNMENT_VARIABLES is enabled (true by default) Backtracking undoes update_array/3 for dynamic arrays, but not for static arrays

Note that update_array/3 actually uses setarg/3 to update elements of dynamic arrays, and setarg/3 spends an extra cell for every update For intensive operations we suggest it may be less expensive to unify each element of the array with a mutable terms and to use the operations on mutable terms

◆ add_to_array_element/4

class add_to_array_element/4

add_to_array_element(+ Name, + Index, + Number, ? NewValue)

Add Number Name[ Index] and unify NewValue with the incremented value Observe that Name[ Index] must be an number If Name is a static array the type of the array must be int or float If the type of the array is int you only may add integers, if it is float you may add integers or floats If Name corresponds to a dynamic array the array element must have been previously bound to a number and Number can be any kind of number

The add_to_array_element/3 built-in actually uses setarg/3 to update elements of dynamic arrays For intensive operations we suggest it may be less expensive to unify each element of the array with a mutable terms and to use the operations on mutable terms

◆ static_array_to_term/2

class static_array_to_term/2

static_array_to_term(? Name, ? Term)

Convert a static array with name Name to a compound term of name Name

This built-in will silently fail if the there is no static array with that name

◆ static_array_location/2

class static_array_location/2

static_array_location(+ Name, - Ptr)

Give the location or memory address for a static array with name Name The result is observed as an integer

Function Documentation

◆ YAP_FetchArray()

void * YAP_FetchArray ( Term  t1,
intptr_t *  sz,
int *  type 
)

Definition at line 703 of file arrays.c.

◆ Yap_InitArrayPreds()

void Yap_InitArrayPreds ( void  )

Definition at line 2698 of file arrays.c.

◆ Yap_StaticArray()

StaticArrayEntry * Yap_StaticArray ( Atom  na,
size_t  dim,
static_array_types  type,
CODEADDR  start_addr,
StaticArrayEntry p 
)

Definition at line 900 of file arrays.c.

◆ Yap_StaticVector()

StaticArrayEntry * Yap_StaticVector ( Atom  Name,
size_t  size,
static_array_types  props 
)

create a new vectir in a given name Name

If one exists, destroy prrexisting onr

Definition at line 1301 of file arrays.c.

Functions

void * YAP_FetchArray (Term t1, intptr_t *sz, int *type)
 
StaticArrayEntryYap_StaticArray (Atom na, size_t dim, static_array_types type, CODEADDR start_addr, StaticArrayEntry *p)
 
StaticArrayEntryYap_StaticVector (Atom Name, size_t size, static_array_types props)
 create a new vectir in a given name Name More...
 
void Yap_InitArrayPreds (void)