W3cubDocs

/Pony

Pointer[A: A]

[Source]

A Pointer[A] is a raw memory pointer. It has no descriptor and thus can't be included in a union or intersection, or be a subtype of any interface. Most functions on a Pointer[A] are private to maintain memory safety.

struct ref Pointer[A: A]

Constructors

create

[Source]

A null pointer.

new ref create()
: Pointer[A] ref^

Returns

_alloc

[Source]

Space for len instances of A.

new ref _alloc(
  len: USize val)
: Pointer[A] ref^

Parameters

Returns

Public Functions

offset

[Source]

Return a tag pointer to the n-th element.

fun tag offset(
  n: USize val)
: Pointer[A] tag

Parameters

Returns

usize

[Source]

Convert the pointer into an integer.

fun tag usize()
: USize val

Returns

is_null

[Source]

Return true for a null pointer, false for anything else.

fun tag is_null()
: Bool val

Returns

eq

[Source]

Return true if this address is that address.

fun tag eq(
  that: Pointer[A] tag)
: Bool val

Parameters

Returns

lt

[Source]

Return true if this address is less than that address.

fun tag lt(
  that: Pointer[A] tag)
: Bool val

Parameters

Returns

ne

[Source]

fun tag ne(
  that: Pointer[A] tag)
: Bool val

Parameters

Returns

le

[Source]

fun tag le(
  that: Pointer[A] tag)
: Bool val

Parameters

Returns

ge

[Source]

fun tag ge(
  that: Pointer[A] tag)
: Bool val

Parameters

Returns

gt

[Source]

fun tag gt(
  that: Pointer[A] tag)
: Bool val

Parameters

Returns

hash

[Source]

Returns a hash of the address.

fun tag hash()
: USize val

Returns

hash64

[Source]

Returns a 64-bit hash of the address.

fun tag hash64()
: U64 val

Returns

Private Functions

_realloc

[Source]

Keep the contents, but reserve space for len instances of A.

fun ref _realloc(
  len: USize val)
: Pointer[A] ref

Parameters

Returns

_unsafe

[Source]

Unsafe change in reference capability.

fun tag _unsafe()
: Pointer[A] ref

Returns

_convert[B: B]

[Source]

Convert from Pointer[A] to Pointer[B].

fun box _convert[B: B]()
: this->Pointer[B] ref

Returns

_apply

[Source]

Retrieve index i.

fun box _apply(
  i: USize val)
: this->A

Parameters

Returns

  • this->A

_update

[Source]

Set index i and return the previous value.

fun ref _update(
  i: USize val,
  value: A!)
: A^

Parameters

Returns

  • A^

_offset

[Source]

Return a pointer to the n-th element.

fun box _offset(
  n: USize val)
: this->Pointer[A] ref

Parameters

Returns

_element_size

[Source]

Return the size of a single element in an array of type A.

fun tag _element_size()
: USize val

Returns

_insert

[Source]

Creates space for n new elements at the head, moving following elements. The array length before this should be len, and the available space should be at least n + len.

fun ref _insert(
  n: USize val,
  len: USize val)
: Pointer[A] ref

Parameters

Returns

_delete

[Source]

Delete n elements from the head of pointer, compact remaining elements of the underlying array. The array length before this should be n + len. Returns the first deleted element.

fun ref _delete(
  n: USize val,
  len: USize val)
: A^

Parameters

Returns

  • A^

_copy_to

[Source]

Copy n elements from this to that.

fun box _copy_to(
  that: Pointer[this->A!] ref,
  n: USize val)
: this->Pointer[A] ref

Parameters

Returns

© 2016-2018, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/builtin-Pointer