List< Type > Class Template Reference

The List class template is used to construct lists of all types, Integer, Real, Complex, Pitch, Rhythm, etc. More...

#include <List.h>

List of all members.

Public Member Functions

 List ()
 Default List constructor.
 List (List Const &L)
 List copy constructor.
 List (Type i_)
 List constructor for a list of length 1.
 List (Type i1_, Type i2_)
 List constructor for a list of length 2.
 List (Type i1_, Type i2_, Type i3_)
 List constructor for a list of length 3.
 List (Type i1_, Type i2_, Type i3_, Type i4_)
 List constructor for a list of length 4.
 List (Type i1_, Type i2_, Type i3_, Type i4_, Type i5_)
 List constructor for a list of length 5.
 List (Type i1_, Type i2_, Type i3_, Type i4_, Type i5_, Type i6_)
 List constructor for a list of length 6.
 List (Type i1_, Type i2_, Type i3_, Type i4_, Type i5_, Type i6_, Type i7_)
 List constructor for a list of length 7.
 List (Type i1_, Type i2_, Type i3_, Type i4_, Type i5_, Type i6_, Type i7_, Type i8_)
 List constructor for a list of length 8.
 List (Type i1_, Type i2_, Type i3_, Type i4_, Type i5_, Type i6_, Type i7_, Type i8_, Type i9_)
 List constructor for a list of length 9.
 List (Type i1_, Type i2_, Type i3_, Type i4_, Type i5_, Type i6_, Type i7_, Type i8_, Type i9_, Type i10_)
 List constructor for a list of length 10.
 List (Type i1_, Type i2_, Type i3_, Type i4_, Type i5_, Type i6_, Type i7_, Type i8_, Type i9_, Type i10_, Type i11_)
 List constructor for a list of length 11.
 List (Type i1_, Type i2_, Type i3_, Type i4_, Type i5_, Type i6_, Type i7_, Type i8_, Type i9_, Type i10_, Type i11_, Type i12_)
 List constructor for a list of length 12.
 List (Type i1_, Type i2_, Type i3_, Type i4_, Type i5_, Type i6_, Type i7_, Type i8_, Type i9_, Type i10_, Type i11_, Type i12_, Type i13_)
 List constructor for a list of length 13.
 List (Type i1_, Type i2_, Type i3_, Type i4_, Type i5_, Type i6_, Type i7_, Type i8_, Type i9_, Type i10_, Type i11_, Type i12_, Type i13_, Type i14_)
 List constructor for a list of length 14.
 List (Type i1_, Type i2_, Type i3_, Type i4_, Type i5_, Type i6_, Type i7_, Type i8_, Type i9_, Type i10_, Type i11_, Type i12_, Type i13_, Type i14_, Type i15_)
 List constructor for a list of length 15.
 List (Type i1_, Type i2_, Type i3_, Type i4_, Type i5_, Type i6_, Type i7_, Type i8_, Type i9_, Type i10_, Type i11_, Type i12_, Type i13_, Type i14_, Type i15_, Type i16_, Type i17_, Type i18_, Type i19_, Type i20_, Type i21_, Type i22_)
 List constructor for a list of length 16.
 ~List ()
 Default List destructor.
Bool operator== (Const List &L)
 List equality operator.
Bool operator!= (Const List &L)
 List inequality operator.
Listoperator+= (Const List &L)
 List concatenation/copy operator, joins lists together.
List operator+ (Const List &L)
 List concatenation operator, joins lists together.
Listoperator= (Const List &L)
 List assignment operator.
Type & operator[] (Integer elem)
 List indexing operator.
Listoperator+= (Const Type x)
 List increment operator, adds Integer to value of all elements of list.
Listoperator-= (Const Type x)
 List decrement operator, subtracts Integer to value from all elements of list.
Listoperator+ (Const Type x)
 List addition operator, adds Integer to value of all elements of list.
Listoperator- (Const Type x)
 List subtraction operator, subtracts Integer to value from all elements of list.
Listoperator * (Const Type x)
 List multiplication operator, multiplies Integer by value of all elements of list.
Listoperator/ (Const Type x)
 List division operator, multiplies Integer by value of all elements of list.
Void print (String s=0)
 List print method.
Void SetListSize (Integer n)
 Preset list to a particular size.
Void checkSize (Integer len)
 List range checking method.
Integer length ()
 List length method.
Type max ()
 List max method.
Integer maxPos ()
 List maxPos method.
Type min ()
 List min method.
Integer minPos ()
 List minPos method.
Void rotate (Integer n, Integer i=0)
 Rotate list by n elements from position i.
Void transpose (Type t, Type lim)
 Offset values of list elements by t modulo lim.
Void invert (Type lim)
 Invert values of list elements at limit.
Void retrograde ()
 Retrograde values of list elements.

Friends

ostream & operator<< (ostream &os, Const List &r)
 Print list to output stream.
Void adjustSize (Integer len, List &r)
 Lists are auto-ranging in size.
istream & operator>> (istream &is, List &r)
 Read a list from the input stream.


Detailed Description

template<class Type>
class List< Type >

The List class template is used to construct lists of all types, Integer, Real, Complex, Pitch, Rhythm, etc.

List automatically adjusts its length to accommodate whatever index is provided, therefore, no initial bounds must be provided when the list is created. Simply indexing an element of the list causes it to come into being, initialized to 0 (for reference), or to the value being assigned.

Definition at line 32 of file List.h.


Constructor & Destructor Documentation

template<class Type>
List< Type >::List (  )  [inline]

Default List constructor.

See also:
~List

Definition at line 85 of file List.h.

Referenced by List< Type >::operator *(), and List< Type >::operator+().

00085 : m_val(0), m_len(0) { }

template<class Type>
List< Type >::List ( List< Type > Const &  L  )  [inline]

List copy constructor.

Parameters:
L List to copy
See also:
~List
Returns:
The copied list

Definition at line 91 of file List.h.

00091                               {
00092                 m_val = new Type [ m_len = L.m_len ];
00093                 memcpy(m_val, L.m_val, sizeof(Type) * m_len);
00094         }

template<class Type>
List< Type >::List ( Type  i_  )  [inline]

List constructor for a list of length 1.

Parameters:
i_ First value
See also:
~List
Returns:
the created list containing one element i_

Definition at line 100 of file List.h.

00100                       { 
00101                 m_val = new Type [ m_len = 1 ];
00102                 m_val[0] = i_; 
00103         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_ 
) [inline]

List constructor for a list of length 2.

Parameters:
i1_ First value
i2_ Second value
See also:
~List
Returns:
the created list containing 2 elements

Definition at line 110 of file List.h.

00110                                   { 
00111                 m_val = new Type [ m_len = 2 ];
00112                 m_val[0] = i1_; 
00113                 m_val[1] = i2_; 
00114         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_ 
) [inline]

List constructor for a list of length 3.

Definition at line 117 of file List.h.

00117                                             {
00118                 m_val = new Type [ m_len = 3 ];
00119                 m_val[0] = i1_; 
00120                 m_val[1] = i2_; 
00121                 m_val[2] = i3_; 
00122         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_ 
) [inline]

List constructor for a list of length 4.

Definition at line 125 of file List.h.

00125                                                       {
00126                 m_val = new Type [ m_len = 4 ];
00127                 m_val[0] = i1_; 
00128                 m_val[1] = i2_; 
00129                 m_val[2] = i3_; 
00130                 m_val[3] = i4_; 
00131         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_,
Type  i5_ 
) [inline]

List constructor for a list of length 5.

Definition at line 134 of file List.h.

00134                                                                 {
00135                 m_val = new Type [ m_len = 5 ];
00136                 m_val[0] = i1_; 
00137                 m_val[1] = i2_; 
00138                 m_val[2] = i3_; 
00139                 m_val[3] = i4_; 
00140                 m_val[4] = i5_; 
00141         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_,
Type  i5_,
Type  i6_ 
) [inline]

List constructor for a list of length 6.

Definition at line 144 of file List.h.

00144                                                                           {
00145                 m_val = new Type [ m_len = 6 ];
00146                 m_val[0] = i1_; m_val[1] = i2_;  m_val[2] = i3_; m_val[3] = i4_; m_val[4] = i5_; m_val[5] = i6_; 
00147         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_,
Type  i5_,
Type  i6_,
Type  i7_ 
) [inline]

List constructor for a list of length 7.

Definition at line 150 of file List.h.

00150                                                                                     {
00151                 m_val = new Type [ m_len = 7 ];
00152                 m_val[0] = i1_; m_val[1] = i2_;  m_val[2] = i3_; m_val[3] = i4_; m_val[4] = i5_; m_val[5] = i6_;  m_val[6] = i7_; 
00153         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_,
Type  i5_,
Type  i6_,
Type  i7_,
Type  i8_ 
) [inline]

List constructor for a list of length 8.

Definition at line 156 of file List.h.

00156                                                                                               {
00157                 m_val = new Type [ m_len = 8 ];
00158                 m_val[0] = i1_; m_val[1] = i2_;  m_val[2] = i3_; m_val[3] = i4_; m_val[4] = i5_; m_val[5] = i6_;  m_val[6] = i7_;  m_val[7] = i8_; 
00159         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_,
Type  i5_,
Type  i6_,
Type  i7_,
Type  i8_,
Type  i9_ 
) [inline]

List constructor for a list of length 9.

Definition at line 162 of file List.h.

00162                                                                                                         {
00163                 m_val = new Type [ m_len = 9 ];
00164                 m_val[0] = i1_; m_val[1] = i2_;  m_val[2] = i3_; m_val[3] = i4_; m_val[4] = i5_; m_val[5] = i6_;  m_val[6] = i7_;  m_val[7] = i8_; 
00165                 m_val[8] = i9_;
00166         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_,
Type  i5_,
Type  i6_,
Type  i7_,
Type  i8_,
Type  i9_,
Type  i10_ 
) [inline]

List constructor for a list of length 10.

Definition at line 169 of file List.h.

00169                                                                                                                    {
00170                 m_val = new Type [ m_len = 10 ];
00171                 m_val[0] = i1_; m_val[1] = i2_;  m_val[2] = i3_; m_val[3] = i4_; m_val[4] = i5_; m_val[5] = i6_;  m_val[6] = i7_;  m_val[7] = i8_; 
00172                 m_val[8] = i9_; m_val[9] = i10_;
00173         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_,
Type  i5_,
Type  i6_,
Type  i7_,
Type  i8_,
Type  i9_,
Type  i10_,
Type  i11_ 
) [inline]

List constructor for a list of length 11.

Definition at line 176 of file List.h.

00176                                                                                                                               {
00177                 m_val = new Type [ m_len = 11 ];
00178                 m_val[0] = i1_; m_val[1] = i2_;  m_val[2] = i3_; m_val[3] = i4_; m_val[4] = i5_; m_val[5] = i6_;  m_val[6] = i7_;  m_val[7] = i8_; 
00179                 m_val[8] = i9_; m_val[9] = i10_; m_val[10] = i11_;
00180         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_,
Type  i5_,
Type  i6_,
Type  i7_,
Type  i8_,
Type  i9_,
Type  i10_,
Type  i11_,
Type  i12_ 
) [inline]

List constructor for a list of length 12.

Definition at line 183 of file List.h.

00183                                                                                                                                          {
00184                 m_val = new Type [ m_len = 12 ];
00185                 m_val[0] = i1_; m_val[1] = i2_;  m_val[2] = i3_; m_val[3] = i4_; m_val[4] = i5_; m_val[5] = i6_;  m_val[6] = i7_;  m_val[7] = i8_; 
00186                 m_val[8] = i9_; m_val[9] = i10_; m_val[10] = i11_; m_val[11] = i12_;
00187         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_,
Type  i5_,
Type  i6_,
Type  i7_,
Type  i8_,
Type  i9_,
Type  i10_,
Type  i11_,
Type  i12_,
Type  i13_ 
) [inline]

List constructor for a list of length 13.

Definition at line 190 of file List.h.

00190                                                                                                                                                     {
00191                 m_val = new Type [ m_len = 13 ];
00192                 m_val[0] = i1_; m_val[1] = i2_;  m_val[2] = i3_; m_val[3] = i4_; m_val[4] = i5_; m_val[5] = i6_;  m_val[6] = i7_;  m_val[7] = i8_; 
00193                 m_val[8] = i9_; m_val[9] = i10_; m_val[10] = i11_; m_val[11] = i12_; m_val[12] = i13_;
00194         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_,
Type  i5_,
Type  i6_,
Type  i7_,
Type  i8_,
Type  i9_,
Type  i10_,
Type  i11_,
Type  i12_,
Type  i13_,
Type  i14_ 
) [inline]

List constructor for a list of length 14.

Definition at line 197 of file List.h.

00197                                                                                                                                                                 {
00198                 m_val = new Type [ m_len = 14 ];
00199                 m_val[0] = i1_; m_val[1] = i2_;  m_val[2] = i3_; m_val[3] = i4_; m_val[4] = i5_; m_val[5] = i6_;  m_val[6] = i7_;  m_val[7] = i8_; 
00200                 m_val[8] = i9_; m_val[9] = i10_; m_val[10] = i11_; m_val[11] = i12_; m_val[12] = i13_; m_val[13] = i14_;
00201         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_,
Type  i5_,
Type  i6_,
Type  i7_,
Type  i8_,
Type  i9_,
Type  i10_,
Type  i11_,
Type  i12_,
Type  i13_,
Type  i14_,
Type  i15_ 
) [inline]

List constructor for a list of length 15.

Definition at line 204 of file List.h.

00204                                                                                                                                                                            {
00205                 m_val = new Type [ m_len = 15 ];
00206                 m_val[0] = i1_; m_val[1] = i2_;  m_val[2] = i3_; m_val[3] = i4_; m_val[4] = i5_; m_val[5] = i6_;  m_val[6] = i7_;  m_val[7] = i8_; 
00207                 m_val[8] = i9_; m_val[9] = i10_; m_val[10] = i11_; m_val[11] = i12_; m_val[12] = i13_; m_val[13] = i14_; m_val[14] = i15_;
00208         }

template<class Type>
List< Type >::List ( Type  i1_,
Type  i2_,
Type  i3_,
Type  i4_,
Type  i5_,
Type  i6_,
Type  i7_,
Type  i8_,
Type  i9_,
Type  i10_,
Type  i11_,
Type  i12_,
Type  i13_,
Type  i14_,
Type  i15_,
Type  i16_,
Type  i17_,
Type  i18_,
Type  i19_,
Type  i20_,
Type  i21_,
Type  i22_ 
) [inline]

List constructor for a list of length 16.

Definition at line 211 of file List.h.

00212                                                                                                {
00213                 m_val = new Type [ m_len = 22 ];
00214                 m_val[0] = i1_; m_val[1] = i2_;  m_val[2] = i3_; m_val[3] = i4_; m_val[4] = i5_; m_val[5] = i6_;  m_val[6] = i7_;  m_val[7] = i8_; 
00215                 m_val[8] = i9_; m_val[9] = i10_; m_val[10] = i11_; m_val[11] = i12_; m_val[12] = i13_; m_val[13] = i14_; m_val[14] = i15_;
00216                 m_val[15] = i16_; m_val[16] = i17_; m_val[17] = i18_; m_val[18] = i19_; m_val[19] = i20_; m_val[20] = i21_; m_val[21] = i22_;
00217         }

template<class Type>
List< Type >::~List (  )  [inline]

Default List destructor.

Definition at line 220 of file List.h.

References If.

00220                 { 
00221                 If ( m_val )
00222                         delete [] m_val; 
00223                 m_val = 0;
00224                 m_len = 0;
00225         }


Member Function Documentation

template<class Type>
Void List< Type >::checkSize ( Integer  len  )  [inline]

List range checking method.

If the list is empty, the list is created. If the list exists, and it is less than length len, then it is reallocated to contain len elements.

Parameters:
len Size to reallocate list, if necessary.
Returns:
Modified list

Definition at line 448 of file List.h.

References Else, and If.

Referenced by List< Type >::operator[]().

00448                                     {
00449                 If (m_val == 0)
00450                         m_val = new Type [ m_len = len+1 ];
00451                 Else If (m_len <= len) {
00452                         m_len = len+1;
00453                         m_val = (Type*) realloc( m_val, m_len * sizeof(Type));
00454                 }
00455         }

template<class Type>
Void List< Type >::invert ( Type  lim  )  [inline]

Invert values of list elements at limit.

Parameters:
lim Limit for inversion

Definition at line 541 of file List.h.

References For, and List< Type >::length().

00541                                 {
00542                 For ( Integer i = 0; i < length(); i = i + 1 ) {
00543                         m_val[ i ] = ( lim - m_val[ i ] ) % lim;
00544                 }
00545         }

template<class Type>
Integer List< Type >::length (  )  [inline]

List length method.

Returns:
Length of the list

Definition at line 459 of file List.h.

References Return.

Referenced by Invert(), List< Type >::invert(), List< Type >::operator!=(), List< Type >::operator==(), List< Type >::retrograde(), List< Type >::rotate(), Transpose(), and List< Type >::transpose().

00459                          { 
00460                 Return m_len; 
00461         }

template<class Type>
Type List< Type >::max (  )  [inline]

List max method.

Returns:
Maximum element of the list

Definition at line 465 of file List.h.

References For, and Return.

Referenced by Max(), and List< Type >::maxPos().

00465                    {
00466                 assert(m_len > 0);
00467                 Type max = m_val[0];
00468                 For ( Integer i = 1; i < m_len; i++ )
00469                         max = m_val[i] < max ? max : m_val[i];
00470                 Return max;
00471         }

template<class Type>
Integer List< Type >::maxPos (  )  [inline]

List maxPos method.

Returns:
index of Maximum element of the list. If multiple elements have the same max. value, this returns the first one.

Definition at line 476 of file List.h.

References For, If, List< Type >::max(), and Return.

00476                          {
00477                 assert(m_len > 0);
00478                 Type max = m_val[0];
00479                 Integer mp = 0;
00480                 For ( Integer i = 1; i < m_len; i++ ) {
00481                         If ( m_val[i] > max ) {
00482                                 max = m_val[i];
00483                                 mp = i;
00484                         }
00485                 }
00486                 Return mp;
00487         }

template<class Type>
Type List< Type >::min (  )  [inline]

List min method.

Returns:
Minimum element of the list

Definition at line 491 of file List.h.

References For, and Return.

Referenced by Min(), and List< Type >::minPos().

00491                    {
00492                 assert(m_len > 0);
00493                 Type min = m_val[0];
00494                 For ( Integer i = 1; i < m_len; i++ )
00495                         min = m_val[i] < min ? m_val[i] : min;
00496                 Return min;
00497         }

template<class Type>
Integer List< Type >::minPos (  )  [inline]

List minPos method.

Returns:
Minimum element of the list If multiple elements have the same max. value, this returns the first one.

Definition at line 502 of file List.h.

References For, If, List< Type >::min(), and Return.

00502                          {
00503                 assert(m_len > 0);
00504                 Type min = m_val[0];
00505                 Integer mp = 0;
00506                 For ( Integer i = 1; i < m_len; i++ ) {
00507                         If ( m_val[i] < min ) {
00508                                 min = m_val[i];
00509                                 mp = i;
00510                         }
00511                 }
00512                 Return mp;
00513         }

template<class Type>
List& List< Type >::operator * ( Const Type  x  )  [inline]

List multiplication operator, multiplies Integer by value of all elements of list.

Parameters:
x Integer value to multiply by all elements of list
Returns:
Modified list

Definition at line 336 of file List.h.

References For, List< Type >::List(), List< Type >::m_val, and Return.

00336                                         {
00337                 List* t = new List (*this);
00338                 *t = *this; // copy this
00339                 For ( Integer i = 0; i < m_len; i++ )
00340                         t->m_val[i] *= x;
00341                 Return( *t );
00342         }

template<class Type>
Bool List< Type >::operator!= ( Const List< Type > &  L  )  [inline]

List inequality operator.

Definition at line 240 of file List.h.

References For, If, List< Type >::length(), Return, and True.

00240                                          {
00241                 If ( L.m_len != m_len )
00242                         Return(True);
00243                 Integer cnt = 0;
00244                 For( Integer i = 0; i < length(); i++ ) {
00245                         If ( L.m_val[i] == m_val[i] )
00246                                 cnt++;
00247                 }
00248                 Return( cnt != m_len );
00249         }

template<class Type>
List& List< Type >::operator+ ( Const Type  x  )  [inline]

List addition operator, adds Integer to value of all elements of list.

Parameters:
x Integer value to add to all elements of list
Returns:
Modified list

Definition at line 314 of file List.h.

References For, List< Type >::List(), List< Type >::m_val, and Return.

00314                                         {
00315                 List* t = new List (*this);
00316                 *t = *this; // copy this
00317                 For ( Integer i = 0; i < m_len; i++ )
00318                         t->m_val[i] += x;
00319                 Return( *t );
00320         }

template<class Type>
List List< Type >::operator+ ( Const List< Type > &  L  )  [inline]

List concatenation operator, joins lists together.

Parameters:
L List to concatenate to this
Returns:
Concatenated lists

Definition at line 264 of file List.h.

References Return.

00264                                         {
00265                 List r = *this;
00266                 r += L;
00267                 Return r;
00268         }

template<class Type>
List& List< Type >::operator+= ( Const Type  x  )  [inline]

List increment operator, adds Integer to value of all elements of list.

Parameters:
x Integer value to add to all elements of list
Returns:
Modified list

Definition at line 296 of file List.h.

References For, and Return.

00296                                          {
00297                 For ( Integer i = 0; i < m_len; i++ )
00298                         m_val[i] += x;
00299                 Return( *this );
00300         }

template<class Type>
List& List< Type >::operator+= ( Const List< Type > &  L  )  [inline]

List concatenation/copy operator, joins lists together.

Parameters:
L List to concatenate to this
Returns:
Concatenated lists

Definition at line 254 of file List.h.

References Return.

00254                                           {
00255                 m_val = (Type*) realloc( m_val, (m_len + L.m_len) * sizeof(Type));
00256                 memcpy(&m_val[m_len], L.m_val, sizeof(Type) * L.m_len);
00257                 m_len += L.m_len;
00258                 Return( *this );
00259         }

template<class Type>
List& List< Type >::operator- ( Const Type  x  )  [inline]

List subtraction operator, subtracts Integer to value from all elements of list.

Parameters:
x Integer value to subtract from all elements of list
Returns:
Modified list

Definition at line 325 of file List.h.

References For, List< Type >::m_val, and Return.

00325                                         {
00326                 List* t = new List [ m_len ];
00327                 *t = *this; // copy this
00328                 For ( Integer i = 0; i < m_len; i++ )
00329                         t->m_val[i] -= x;
00330                 Return( *t );
00331         }

template<class Type>
List& List< Type >::operator-= ( Const Type  x  )  [inline]

List decrement operator, subtracts Integer to value from all elements of list.

Parameters:
x Integer value to subtract from all elements of list
Returns:
Modified list

Definition at line 305 of file List.h.

References For, and Return.

00305                                          {
00306                 For ( Integer i = 0; i < m_len; i++ )
00307                         m_val[i] -= x;
00308                 Return( *this );
00309         }

template<class Type>
List& List< Type >::operator/ ( Const Type  x  )  [inline]

List division operator, multiplies Integer by value of all elements of list.

Parameters:
x Integer value to divide by all elements of list
Returns:
Modified list

Definition at line 347 of file List.h.

References For, List< Type >::m_val, and Return.

00347                                         {
00348                 List* t = new List [ m_len ];
00349                 *t = *this; // copy this
00350                 For ( Integer i = 0; i < m_len; i++ )
00351                         t->m_val[i] /= x;
00352                 Return( *t );
00353         }

template<class Type>
List& List< Type >::operator= ( Const List< Type > &  L  )  [inline]

List assignment operator.

Parameters:
L List to assign to this
Returns:
Assigned list

Definition at line 273 of file List.h.

References If, and Return.

00273                                          {
00274                 If (this == &L)
00275                         Return *this;
00276                 If (m_val != 0)
00277                         delete [] m_val;
00278                 m_val = new Type [ m_len = L.m_len ];
00279                 memcpy(m_val, L.m_val, sizeof(Type) * m_len);
00280                 Return( *this );
00281         }

template<class Type>
Bool List< Type >::operator== ( Const List< Type > &  L  )  [inline]

List equality operator.

Two lists are equal if they have the same length and all elements in corresponding positions are identical.

Definition at line 229 of file List.h.

References False, For, If, List< Type >::length(), Return, and True.

00229                                          {
00230                 If ( L.m_len != m_len )
00231                         Return(False);
00232                 For( Integer i = 0; i < length(); i++ ) {
00233                         If ( L.m_val[i] != m_val[i] )
00234                                 Return( False );
00235                 }
00236                 Return( True );
00237         }

template<class Type>
Type& List< Type >::operator[] ( Integer  elem  )  [inline]

List indexing operator.

Performs range checking.

Parameters:
elem Integer index of list element to return
Returns:
Indexed list element

Definition at line 287 of file List.h.

References List< Type >::checkSize(), and Return.

00287                                          {
00288                 assert( elem >= 0);
00289                 checkSize(elem);
00290                 Return m_val[elem];
00291         }

template<class Type>
Void List< Type >::print ( String  s = 0  )  [inline]

List print method.

Parameters:
s String value to print at head of list.

Definition at line 419 of file List.h.

References For, and If.

00419                                  {
00420                 If (s)
00421                         cout << s;
00422                 cout << "{ ";
00423                 cout.precision(2);
00424                 For (Integer i = 0; i < m_len-1; i++)
00425                         cout << m_val[i] << ", ";
00426                 cout << m_val[m_len-1];
00427                 cout << " }" << endl;
00428         }

template<class Type>
Void List< Type >::retrograde (  )  [inline]

Retrograde values of list elements.

Definition at line 548 of file List.h.

References For, and List< Type >::length().

00548                            {
00549                 Integer n = length( );
00550                 Type* t = new Type [ m_len ];
00551                 memcpy(t, m_val, sizeof(Type) * m_len);
00552                 For ( Integer i = 0; i < n; i = i + 1 )
00553                         m_val[ i ] = t[ n - i - 1 ];
00554         }

template<class Type>
Void List< Type >::rotate ( Integer  n,
Integer  i = 0 
) [inline]

Rotate list by n elements from position i.

Parameters:
i Starting position, usually set to 0.
n Number of elements to rotate. Positive n rotates counterclockwise; negative n rotates clockwise.

Definition at line 518 of file List.h.

References If, List< Type >::length(), Mod(), and PosMod().

00518                                                 {
00519                 n = Mod( n, length() );                 // constrain rotation to length of list
00520                 Type x = m_val[ i ];                    // store f[ i ] for use after recursion
00521                 If ( i < length() - 1 )                 // reached the end?
00522                         rotate( n, i+1 );                       // no, set up next element via recursion
00523                 // We continue from here when the recursion unwinds
00524                 Integer pos = PosMod( i+n, length() );  // index list modulo its length
00525                 m_val[ pos ] = x;                               // assign value of x saved above
00526         }

template<class Type>
Void List< Type >::SetListSize ( Integer  n  )  [inline]

Preset list to a particular size.

Definition at line 431 of file List.h.

References Else, and If.

00431                                     {
00432         If(m_val)
00433                         delete[] m_val;
00434         If (n > 0) {
00435             m_val = new Type[n];
00436             memset( m_val, 0, sizeof(Type) * n / sizeof(char) );
00437         }
00438         Else 
00439                         m_val = NULL;
00440         m_len = n;
00441     }

template<class Type>
Void List< Type >::transpose ( Type  t,
Type  lim 
) [inline]

Offset values of list elements by t modulo lim.

Note: uses PosMod() to preserve elements within the interval 0..lim.

Parameters:
t Transposition value
lim Transposition limit

Definition at line 532 of file List.h.

References For, List< Type >::length(), and PosMod().

00532                                            {
00533                 For ( Integer i = 0; i < length(); i = i + 1 ) {
00534                         Type x = m_val[ i ] + t;
00535                         m_val[ i ] = PosMod(x, lim);
00536                 }
00537         }


Friends And Related Function Documentation

template<class Type>
Void adjustSize ( Integer  len,
List< Type > &  r 
) [friend]

Lists are auto-ranging in size.

This function reallocates the memory for a list to match its length requirements.

Definition at line 53 of file List.h.

00053                                                       {
00054                 If (r.m_val == 0) {
00055                         r.m_val = new Type [ r.m_len = len+1 ];
00056                 } Else If (r.m_len <= len) {
00057                         r.m_len = len+1;
00058                         r.m_val = (Type*) realloc( r.m_val, r.m_len * sizeof(Type));
00059                 }
00060          }

template<class Type>
ostream& operator<< ( ostream &  os,
Const List< Type > &  r 
) [friend]

Print list to output stream.

List is printed as '{' <elem0> ',' <elem1> ',' ... '}'

Definition at line 36 of file List.h.

00036                                                               {
00037                 If (r.m_len > 0)
00038                         os << "(";
00039                 for (Integer i = 0; i < r.m_len; i++) {
00040                         os << r.m_val[i];
00041                         If (i != r.m_len-1)
00042                                 os << ", ";
00043                         Else
00044                                 os << ")";
00045                 }
00046                 os << endl;
00047                 Return os;
00048          }

template<class Type>
istream& operator>> ( istream &  is,
List< Type > &  r 
) [friend]

Read a list from the input stream.

List is read as '(' <elem0> ',' <elem1> ',' ... ')'

Definition at line 64 of file List.h.

00064                                                           {
00065                  char ch;
00066                  Type t;
00067                  Integer len = 0;
00068                  is >> ch;
00069                  If (ch != '{' And ch != '(')
00070                          Return is;
00071                  While (is >> t >> ch And ch == ',') {
00072                         adjustSize(len, r);
00073                         r.m_val[len++] = t;
00074                  }
00075                 adjustSize(len, r);
00076                 r.m_val[len++] = t;
00077                 assert( ch == '}' || ch == ')');
00078                 Return is;
00079          }


The documentation for this class was generated from the following file:
Generated on Fri Sep 8 23:21:13 2006 for MusimatLib by  doxygen 1.4.7