Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 2589

Show
Ignore:
Timestamp:
09/30/07 00:15:22 (1 year ago)
Author:
kris
Message:

fixes #579

added a toArray() method on all collections, which copies collection values into an array

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/util/collection/ArraySeq.d

    r2465 r2589  
    905905                         Cout (value).newline; 
    906906 
    907                 array.checkImplementation(); 
     907                auto a = array.toArray; 
     908                foreach (value; a) 
     909                         Cout (value).newline; 
     910 
     911                 array.checkImplementation(); 
    908912        } 
    909913} 
  • trunk/tango/util/collection/impl/Collection.d

    r2465 r2589  
    9797 
    9898        // Default implementations of Collection methods 
     99 
     100        /*********************************************************************** 
     101 
     102                expose collection content as an array 
     103 
     104        ************************************************************************/ 
     105 
     106        public T[] toArray () 
     107        { 
     108                auto result = new T[this.size]; 
     109         
     110                int i = 0; 
     111                foreach (e; this) 
     112                         result[i++] = e; 
     113 
     114                return result; 
     115        } 
    99116 
    100117        /*********************************************************************** 
  • trunk/tango/util/collection/model/View.d

    r2465 r2589  
    168168 
    169169        /** 
     170         expose collection content as an array 
     171        **/ 
     172 
     173        public T[] toArray (); 
     174 
     175        /** 
    170176         * Report whether other has the same element structure as this. 
    171177         * That is, whether other is of the same size, and has the same