FoscTypedSequenceableCollection

Returns a FoscTypedSequenceableCollection.


Description

A typed sequenceable collection.


Attributes Summary

Instance Properties

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

Instance Methods: Comparison

==
!=

Instance Methods: Enumeration

do
iter

Instance Methods: Properties

includes
isCollection
items
size Size of typed sequenceable collection.

Instance Methods: List Modification

pop Removes last item.
remove Remove item.
removeAt Remove item at index.

Instance Methods: Transformation

collect
reject
select


Usage

  1. Example

    x = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    x.collection;
    [ 1, 2, 3, 4 ]
    x.items;
    [ 1, 2, 3, 4 ]
    FoscTypedSequenceableCollection.dumpInterface
    FoscTypedSequenceableCollection


Instance Properties


at

Gets item at index.

Returns item.

  1. Example

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


atAll

Gets items at indices.

Returns items.

  1. Example

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


copySeries

  1. Example

    a = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    a[1..2];
    [ 2, 3 ]
    a = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    a[1..];
    [ 2, 3, 4 ]
    a = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    a[..2];
    [ 1, 2, 3 ]
    a = FoscTypedSequenceableCollection([1, 2, 3, 4, 5, 6, 7], Number);
    a.copySeries(0, 2);
    [ 1, 3, 5, 7 ]


includes

Answer true if item exists in collection.

Returns boolean.

  1. Example

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


indexOf

(abjad: index)

Return the first index matching item.

Returns integer.

  1. Example

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


last

Return the last item.

  1. Example

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


occurrencesOf

(abjad: count)

Return the number of occurrences of item in collection.

Returns integer.

  1. Example

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


Instance Methods: Comparison


==

  1. Example

    a = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    b = FoscTypedSequenceableCollection([1, 2], Number);
    a == b;
    false
    a == a.copy;
    true


!=

  1. Example

    a = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    b = FoscTypedSequenceableCollection([1, 2], Number);
    a != b;
    true
    a != a.copy;
    false


Instance Methods: Enumeration


do

  1. Example

    x = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    x.do { |each| (each * 2).postln };
    [ 1, 2, 3, 4 ]


iter

  1. Example

    a = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    a = a.iter;
    5.collect { a.next };
    [ 1, 2, 3, 4, nil ]


Instance Methods: Properties


includes

  1. Example

    a = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    a.includes(4);
    true


isCollection

  1. Example

    a = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    a.isCollection;
    true


items

  1. Example

    x = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    x.items;
    [ 1, 2, 3, 4 ]


size

Size of typed sequenceable collection.

Returns nonnegative integer.

  1. Example

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


Instance Methods: List Modification


pop

Removes last item.

  1. Returns removed item

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


remove

Remove item.

Returns removed item.

  1. Example

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


removeAt

Remove item at index.

Returns removed item.

  1. Example

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


Instance Methods: Transformation


collect

  1. Example

    x = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    x = x.collect { |each| each * 2 };
    x.inspect;
    FoscTypedSequenceableCollection([
        2,
        4,
        6,
        8
    ])


reject

  1. Example

    x = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    x = x.reject { |each| each.even };
    x.inspect;
    FoscTypedSequenceableCollection([
        1,
        3
    ])


select

  1. Example

    x = FoscTypedSequenceableCollection([1, 2, 3, 4], Number);
    x = x.select { |each| each.even };
    x.inspect;
    FoscTypedSequenceableCollection([
        2,
        4
    ])