FoscTypedArray

Returns a FoscTypedArray.


Description

A typed array.


Attributes Summary

Instance Methods: List Modification

++ Concatenates typed list and expr.
append Appends item to typed array.
addAll
insert Insert item at index.
prepend Prepends item to typed array.
put Put item at index.
remove Remove item.
removeAt Remove item at index.
sort Sort the contents of the collection using optional comparison function.

Instance Methods: Properties

at Gets item at index.
atAll Gets items at indices.
includes Answer true if item exists in collection.
indexOf (abjad: index)
occurrencesOf (abjad: count)

Instance Methods: Display

inspect Inspect items in collection.


Usage

  1. Example

    x = FoscTypedArray([1, 2, 3, 4], Number);
    x.cs;
    FoscTypedArray([
        1,
        2,
        3,
        4
    ])


Instance Methods: List Modification


++

Concatenates typed list and expr.

Returns new typed list.

  1. FIXME ERROR: Meta_FoscTypedArray:new: item a FoscTypedArray is the wrong type: FoscTypedArray.

    a = FoscTypedArray([1, 2, 3, 4], Number);
    b = FoscTypedArray([5, 6], Number);
    (a ++ b).items;
    a = FoscTypedArray([1, 2, 3, 4], Number);
    b = [5, 6]; // coerce to itemClass
    (a ++ b).items;
    [ 5, 6 ]


append

Appends item to typed array.

Returns new typed array.

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a = a.add(5);
    a.items;
    [ 1, 2, 3, 4, 5 ]


addAll

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a = a.addAll([5, 6, 7]);
    a.items;
    prFormatCodeString interpret initial failed: a DoesNotUnderstandError
    
        a = FoscTypedArray([1, 2, 3, 4], Number);
        a = a.addAll([5, 6, 7]);
    


insert

Insert item at index.

Returns new typed array.

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a = a.insert(2, 99);
    a.items;
    [ 1, 2, 99, 3, 4 ]


prepend

Prepends item to typed array.

Returns new typed array.

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a = a.prepend(5);
    a.items;
    [ 5, 1, 2, 3, 4 ]


put

Put item at index.

Returns new typed array.

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a = a.put(2, 99);
    a.items;
    [ 1, 2, 99, 4 ]


remove

Remove item.

Returns removed item.

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a.remove(2);
    a.items;
    [ 1, 3, 4 ]


removeAt

Remove item at index.

Returns removed item.

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a.removeAt(1);
    a.items;
    [ 1, 3, 4 ]


sort

Sort the contents of the collection using optional comparison function.

Returns new typed array.

  1. Example

    a = FoscTypedArray([5, 2, 3, 4], Number);
    a = a.sort;
    a.items;
    [ 2, 3, 4, 5 ]
    a = FoscTypedArray([5, 2, 3, 4], Number);
    a = a.sort { |a, b| a > b };
    a.items;
    [ 5, 4, 3, 2 ]


Instance Methods: Properties


at

Gets item at index.

Returns item.

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a[2];
    3


atAll

Gets items at indices.

Returns items.

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a[(2..3)];
    [ 3, 4 ]


includes

Answer true if item exists in collection.

Returns boolean.

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a.includes(3);
    a.includes(5);
    false


indexOf

(abjad: index)

Return the first index matching item.

Returns nonnegative integer.

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a.indexOf(3);
    2


occurrencesOf

(abjad: count)

Return the number of occurrences of item in collection.

Returns nonnegative integer.

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a.occurrencesOf(3);
    1


Instance Methods: Display


inspect

Inspect items in collection.

  1. Example

    a = FoscTypedArray([1, 2, 3, 4], Number);
    a.inspect;
    FoscTypedArray([
        1,
        2,
        3,
        4
    ])