FoscCyclicArray

Returns a FoscCyclicArray.


Description

Cyclic array.

Cyclic arrays overload the item-getting method of built-in arrays.

Cyclic arrays return a value for any integer index.

Cyclic arrays otherwise behave exactly like built-in arrays.


Attributes Summary

Instance Properties

items Gets items in cyclic tuple.

Instance Methods: Special Methods

includes (abjad: container)
== Is true when argument is a tuple with items equal to those of this cyclic tuple. Otherwise false.
at Gets item or slice identified by argument. Returns nil when no item exists at index.
atAll
copySeries (abjad: _get_slice)
hash Hashes cyclic tuple.
iter Iterates cyclic tuple. Iterates items only once.
size Gets length of cyclic tuple.
str Gets string representation of cyclic tuple.


Usage

  1. Example

    a = FoscCyclicArray(#[a, b, c, d]);
    (0..12).collect { |i| a[i] };
    [ 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a' ]


Instance Properties


items

Gets items in cyclic tuple.

Returns array.


Instance Methods: Special Methods


includes

(abjad: container)

Is true when cyclic tuple contains item.

Returns true or false.


==

Is true when argument is a tuple with items equal to those of this cyclic tuple. Otherwise false.

Returns true or false.


at

Gets item or slice identified by argument. Returns nil when no item exists at index.

Returns item.


atAll


copySeries

(abjad: _get_slice)

  1. Example

    a = FoscCyclicArray(#[a,b,c,d,e,f]);
    a[0..12];
    [ 'a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f', 'a' ]
    a = FoscCyclicArray(#[a,b,c,d,e,f]);
    a[..12];
    [ 'a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f', 'a' ]
    a = FoscCyclicArray(#[a,b,c,d,e,f]);
    a[3..17];
    [ 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f', 'a', 'b', 'c', 'd', 'e', 'f' ]
    a = FoscCyclicArray(#[a,b,c,d,e,f]);
    a[0, 2 .. 15];
    [ 'a', 'c', 'e', 'a', 'c', 'e', 'a', 'c' ]


hash

Hashes cyclic tuple.

Returns integer.


iter

Iterates cyclic tuple. Iterates items only once.

Does not iterate infinitely.


size

Gets length of cyclic tuple.

Returns nonnegative integer.


str

Gets string representation of cyclic tuple.

Returns string.