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

Changeset 3740

Show
Ignore:
Timestamp:
07/10/08 06:08:16 (5 months ago)
Author:
sean
Message:

* Renamed 'unique' to 'distinct'
* Fixed docs for this routine to more accurately reflect what it does

This closes #1126

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/core/Array.d

    r3233 r3740  
    16841684     * 
    16851685     * Returns: 
    1686      *  The number of unique elements in buf. 
    1687      */ 
    1688     size_t unique( Elem[] buf, Pred2E pred = Pred2E.init ); 
     1686     *  The number of distinct sub-sequences in buf. 
     1687     */ 
     1688    size_t distinct( Elem[] buf, Pred2E pred = Pred2E.init ); 
    16891689} 
    16901690else 
    16911691{ 
    1692     template unique_( Elem, Pred = IsEqual!(Elem) ) 
     1692    template distinct_( Elem, Pred = IsEqual!(Elem) ) 
    16931693    { 
    16941694        static assert( isCallableType!(Pred) ); 
     
    17271727 
    17281728 
    1729     template unique( Buf ) 
    1730     { 
    1731         size_t unique( Buf buf ) 
    1732         { 
    1733             return unique_!(ElemTypeOf!(Buf)).fn( buf ); 
    1734         } 
    1735     } 
    1736  
    1737  
    1738     template unique( Buf, Pred ) 
    1739     { 
    1740         size_t unique( Buf buf, Pred pred ) 
    1741         { 
    1742             return unique_!(ElemTypeOf!(Buf), Pred).fn( buf, pred ); 
     1729    template distinct( Buf ) 
     1730    { 
     1731        size_t distinct( Buf buf ) 
     1732        { 
     1733            return distinct_!(ElemTypeOf!(Buf)).fn( buf ); 
     1734        } 
     1735    } 
     1736 
     1737 
     1738    template distinct( Buf, Pred ) 
     1739    { 
     1740        size_t distinct( Buf buf, Pred pred ) 
     1741        { 
     1742            return distinct_!(ElemTypeOf!(Buf), Pred).fn( buf, pred ); 
    17431743        } 
    17441744    } 
     
    17511751        void test( char[] buf, char[] pat ) 
    17521752        { 
    1753             assert( unique( buf ) == pat.length ); 
     1753            assert( distinct( buf ) == pat.length ); 
    17541754            foreach( pos, cur; pat ) 
    17551755            {