1 List : SequenceableCollection {
4 *new { arg size = 8; ^super.new.setCollection(Array.new(size)); }
5 *newClear { arg size = 0;
7 ^super.new.setCollection(Array.new(8));
9 ^super.new.setCollection(Array.newClear(size));
12 *copyInstance { arg aList; ^super.new.array_( aList.array.copy ) }
13 *newUsing { arg anArray;
14 // an array is supplied to use directly
15 ^super.new.setCollection( anArray )
18 asArray { ^array.copy }
19 copy { ^this.class.copyInstance(this) }
20 copyRange { arg start, end; ^this.class.newUsing(array.copyRange(start, end)) }
21 copySeries { arg first, second, last;
22 ^this.class.newUsing(array.copySeries(first, second, last))
24 putSeries { arg first, second, last, value;
25 array.putSeries(first, second, last, value);
28 grow { arg sizeIncrease; array = array.grow(sizeIncrease); }
30 dump { "List's array:\n".post; array.dump }
33 this.setCollection(Array.new(8));
38 at { arg i; ^array.at(i) }
39 clipAt { arg i; i = i.asInteger.clip(0, this.size - 1); ^array.at(i) }
40 wrapAt { arg i; i = i.asInteger.wrap(0, this.size - 1); ^array.at(i) }
41 foldAt { arg i; i = i.asInteger.fold(0, this.size - 1); ^array.at(i) }
43 put { arg i, item; array.put(i, item) }
44 clipPut { arg i, item; i = i.asInteger.clip(0, this.size - 1); ^array.put(i, item) }
45 wrapPut { arg i, item; i = i.asInteger.wrap(0, this.size - 1); ^array.put(i, item) }
46 foldPut { arg i, item; i = i.asInteger.fold(0, this.size - 1); ^array.put(i, item) }
48 add { arg item; array = array.add(item); }
49 addFirst { arg item; array = array.addFirst(item); }
50 insert { arg index, item; array = array.insert(index, item); }
51 removeAt { arg index; ^array.removeAt(index); }
53 first { if (this.size > 0, { ^array.at(0) }, { ^nil }) }
54 last { if (this.size > 0, { ^array.at(this.size - 1) }, { ^nil }) }
55 fill { arg item; array.fill(item) }
61 reverseDo { arg function;
62 array.reverseDo(function);
64 pairsDo { arg function;
65 array.pairsDo(function);
67 doAdjacentPairs { arg function;
68 array.doAdjacentPairs(function);
72 swap { arg i,j; array.swap(i, j) }
75 ^this.class.newUsing(array.reverse);
78 ^this.class.newUsing(array.rotate(n));
81 ^this.class.newUsing(array.stutter(n));
84 ^this.class.newUsing(array.mirror);
87 ^this.class.newUsing(array.mirror2);
90 ^this.class.newUsing(array.mirror1);
93 ^this.class.newUsing(array.scramble);
95 permute { arg nthPermutation;
96 ^this.class.newUsing(array.permute(nthPermutation));
98 wrapExtend { arg length;
99 ^this.class.newUsing(array.wrapExtend(length));
101 foldExtend { arg length;
102 ^this.class.newUsing(array.foldExtend(length));
104 pyramid { arg patternType=1; // an integer from 1-10
105 ^this.class.newUsing(array.pyramid(patternType));
108 ^this.class.newUsing(array.lace(length))
110 slide { arg windowLength=3, stepSize=1;
111 ^this.class.newUsing(array.slide(windowLength, stepSize));
115 setCollection { arg aColl;
116 array = aColl.asArray;