Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual C++
STL/CLR Library
set (STL/CLR)
 set::find

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual C++ Libraries
set::find (STL/CLR)

Finds an element that matches a specified key.

    iterator find(key_type key);
key

Key value to search for.

If at least one element in the controlled sequence has equivalent ordering with key, the member function returns an iterator designating one of those elements; otherwise it returns set::end (STL/CLR)(). You use it to locate an element currently in the controlled sequence that matches a specified key.

// cliext_set_find.cpp 
// compile with: /clr 
#include <cliext/set> 
 
typedef cliext::set<wchar_t> Myset; 
int main() 
    { 
    Myset c1; 
    c1.insert(L'a'); 
    c1.insert(L'b'); 
    c1.insert(L'c'); 
 
// display initial contents " a b c" 
    for each (wchar_t elem in c1) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
    System::Console::WriteLine("find {0} = {1}", 
        L'A', c1.find(L'A') != c1.end()); 
    System::Console::WriteLine("find {0} = {1}", 
        L'b', *c1.find(L'b')); 
    System::Console::WriteLine("find {0} = {1}", 
        L'C', c1.find(L'C') != c1.end()); 
    return (0); 
    } 
 
 a b c
find A = False
find b = b
find C = False

Note that find does not guarantee which of several element it finds.

Header: <cliext/set>

Namespace: cliext

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker