www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3402] New: Please bring back canFind in std.algorithm

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3402

           Summary: Please bring back canFind in std.algorithm
           Product: D
           Version: 2.034
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com


--- Comment #0 from David Simcha <dsimcha yahoo.com> 2009-10-14 13:54:53 PDT ---
Sometimes in non-performance-critical code, it's nice to be able to see whether
a value is in a range in one line of code, in a straightforward way.  There is
no *clean, straightforward* way to do this with std.algorithm.find.  The old
std.algorithm had a canFind() function.  The canFindSorted() function was
retained and I find it extremely useful for building space-efficient finite
sets from arrays.  Please bring back canFind().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 14 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3402


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei metalanguage.com


--- Comment #1 from Andrei Alexandrescu <andrei metalanguage.com> 2009-10-14
18:48:33 PDT ---
I was hoping that find(...).empty is brief enough. Isn't it?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 14 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3402


Max Samukha <samukha voliacable.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |samukha voliacable.com


--- Comment #2 from Max Samukha <samukha voliacable.com> 2009-10-14 23:39:33
PDT ---
It is. But a note in the docs would be nice. An example would be enough:

// Checking if the element can be found in the range
assert(find(a, 5).empty);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 14 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3402


David Simcha <dsimcha yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


--- Comment #3 from David Simcha <dsimcha yahoo.com> 2009-10-15 06:26:13 PDT ---
Sounds good.  I just never realized it was this easy.  I'll close this bug
report.  Just please keep canFindSorted because find(assumeSorted(...)).empty
is just too much typing when using an array as a space-efficient finite set.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 15 2009