Click here to Skip to main content
15,895,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWhat's the difference between CDialog and CView Pin
Happy frog26-Apr-06 18:45
Happy frog26-Apr-06 18:45 
AnswerRe: What's the difference between CDialog and CView Pin
Hamid_RT26-Apr-06 19:17
Hamid_RT26-Apr-06 19:17 
QuestionC++ STL Question: Using Maps Pin
chasetoys26-Apr-06 17:59
chasetoys26-Apr-06 17:59 
AnswerRe: C++ STL Question: Using Maps Pin
Stephen Hewitt26-Apr-06 18:04
Stephen Hewitt26-Apr-06 18:04 
AnswerRe: C++ STL Question: Using Maps Pin
Christian Graus26-Apr-06 18:07
protectorChristian Graus26-Apr-06 18:07 
GeneralRe: C++ STL Question: Using Maps Pin
chasetoys26-Apr-06 18:15
chasetoys26-Apr-06 18:15 
GeneralRe: C++ STL Question: Using Maps Pin
Christian Graus26-Apr-06 18:30
protectorChristian Graus26-Apr-06 18:30 
GeneralRe: C++ STL Question: Using Maps Pin
Stephen Hewitt26-Apr-06 18:54
Stephen Hewitt26-Apr-06 18:54 
You can get the best of both worlds by combining the two: use a std::map for fast access to data but a std::vector of std::map::iterators into the std::map which you can shuffle. Here's an example using sets.
------------
// Console.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;

typedef std::set<string> StringSet;
typedef StringSet::const_iterator StringSet_CI;
typedef std::vector<StringSet_CI> StringSetIterators;
typedef StringSetIterators::const_iterator StringSetIterators_CI;

int main(int argc, char* argv[])
{
const char* Names[] = {"Bob", "Sue", "James", "Ralph", "Steve", "Paul", "Kim", "Mary"};
const char** pEndNames = &Names[sizeof(Names)/sizeof(Names[0])];

// A map of strings.
StringSet strings;

// Fill the set with the names.
copy(Names, pEndNames, inserter(strings, strings.end()));

// Output the set to the console.
cout << "Names in set:" << endl;
copy(strings.begin(), strings.end(), ostream_iterator<string>(cout, "\n"));
cout << endl << endl;

// Vector of set iterators.
StringSetIterators ssi;
StringSet_CI e = strings.end();
for ( StringSet_CI i=strings.begin(); i!=e; ++i )
{
ssi.push_back(i);
}

for ( int times=1; times<=3; ++times )
{
// Shuffle the iterators.
random_shuffle(ssi.begin(), ssi.end());

// Output through the shuffled iterators.
cout << "Shuffled names:" << endl;
StringSetIterators_CI ee = ssi.end();
for ( StringSetIterators_CI ii=ssi.begin(); ii!=ee; ++ii )
{
cout << *(*ii) << endl;
}
cout << endl << endl;
}

return 0;
}


Steve
GeneralRe: C++ STL Question: Using Maps Pin
Stephen Hewitt26-Apr-06 18:19
Stephen Hewitt26-Apr-06 18:19 
GeneralRe: C++ STL Question: Using Maps Pin
Christian Graus26-Apr-06 18:26
protectorChristian Graus26-Apr-06 18:26 
GeneralRe: C++ STL Question: Using Maps Pin
Stephen Hewitt26-Apr-06 18:29
Stephen Hewitt26-Apr-06 18:29 
GeneralRe: C++ STL Question: Using Maps Pin
Christian Graus26-Apr-06 18:36
protectorChristian Graus26-Apr-06 18:36 
GeneralRe: C++ STL Question: Using Maps Pin
Stephen Hewitt26-Apr-06 18:57
Stephen Hewitt26-Apr-06 18:57 
GeneralRe: C++ STL Question: Using Maps Pin
Steve Echols26-Apr-06 19:42
Steve Echols26-Apr-06 19:42 
GeneralRe: C++ STL Question: Using Maps Pin
Stephen Hewitt26-Apr-06 19:46
Stephen Hewitt26-Apr-06 19:46 
GeneralRe: C++ STL Question: Using Maps Pin
Steve Echols26-Apr-06 19:53
Steve Echols26-Apr-06 19:53 
GeneralRe: C++ STL Question: Using Maps Pin
Stephen Hewitt26-Apr-06 19:58
Stephen Hewitt26-Apr-06 19:58 
GeneralRe: C++ STL Question: Using Maps Pin
Steve Echols26-Apr-06 20:14
Steve Echols26-Apr-06 20:14 
GeneralRe: C++ STL Question: Using Maps Pin
Christian Graus26-Apr-06 21:02
protectorChristian Graus26-Apr-06 21:02 
GeneralRe: C++ STL Question: Using Maps Pin
chasetoys26-Apr-06 18:30
chasetoys26-Apr-06 18:30 
GeneralRe: C++ STL Question: Using Maps Pin
Stephen Hewitt26-Apr-06 20:04
Stephen Hewitt26-Apr-06 20:04 
QuestionDouble Limit Pin
Stan the man26-Apr-06 17:31
Stan the man26-Apr-06 17:31 
AnswerRe: Double Limit Pin
Stephen Hewitt26-Apr-06 18:10
Stephen Hewitt26-Apr-06 18:10 
GeneralRe: Double Limit Pin
Stan the man27-Apr-06 4:23
Stan the man27-Apr-06 4:23 
GeneralRe: Double Limit Pin
Stephen Hewitt27-Apr-06 13:50
Stephen Hewitt27-Apr-06 13:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.