 |
Changeset 3740
- 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
| r3233 |
r3740 |
|
| 1684 | 1684 | * |
|---|
| 1685 | 1685 | * 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 ); |
|---|
| 1689 | 1689 | } |
|---|
| 1690 | 1690 | else |
|---|
| 1691 | 1691 | { |
|---|
| 1692 | | template unique_( Elem, Pred = IsEqual!(Elem) ) |
|---|
| | 1692 | template distinct_( Elem, Pred = IsEqual!(Elem) ) |
|---|
| 1693 | 1693 | { |
|---|
| 1694 | 1694 | static assert( isCallableType!(Pred) ); |
|---|
| … | … | |
| 1727 | 1727 | |
|---|
| 1728 | 1728 | |
|---|
| 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 ); |
|---|
| 1743 | 1743 | } |
|---|
| 1744 | 1744 | } |
|---|
| … | … | |
| 1751 | 1751 | void test( char[] buf, char[] pat ) |
|---|
| 1752 | 1752 | { |
|---|
| 1753 | | assert( unique( buf ) == pat.length ); |
|---|
| | 1753 | assert( distinct( buf ) == pat.length ); |
|---|
| 1754 | 1754 | foreach( pos, cur; pat ) |
|---|
| 1755 | 1755 | { |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic