pair

What is std::pair?

What is std::pair for, why would I use it, and what benefits does boost::compressed_pair bring? ...

What is C# analog of C++ std::pair?

I am interested what is C# analog of C++ std::pair? I have found System.Web.UI.Pair class, but wanted something template based. Thank you! ...

Is there a standard C++ function object for taking apart a std::pair?

Does anyone know if there's a de-facto standard (i.e., TR1 or Boost) C++ function object for accessing the elements of a std::pair? Twice in the past 24 hours I've wished I had something like the keys function for Perl hashes. For example, it would be nice to run std::transform on a std::map object and dump all the keys (or values) to ...

What are and how do I use OpenSSL BIO pairs?

What exactly is a BIO pair in OpenSSL, and how is it intended to be used? I've already checked the OpenSSL docs, but any details are few and far between. Thanks! ...

How to create a "Pair" function to match against a string list?

I was doing an exercise on F# Wiki Book on List (scroll to the bottom) to create a Pair method. I was able to pair a integer list without problem but an F# exception was thrown for a string list. It is just too cryptic for me to decipher what the exception means for an F# beginner like me. Here is my initial attempt to implementing Pa...

Is it possible to use a custom class in place of std::pair in an STL map?

Is this possible? #include <map> class Example { private: std::map<std::string, std::string, less<std::string>, std::allocator< CustomPair<std::string, std::string> > > myMap; }; In the example above, CustomPair would be a template class holding a key and value. If this is possible, is it that simple or is there anything I s...

Keeping a pair of primitives in a Java HashMap

I have a list of files. I would like to scan through and keep a count of the number of files with the same size. the issue is with filesize which is a long, as we know, hashmap will take in only an object and not a primitive. So using new Long(filesize), i put it into the hashmap. instead of getting a pair of (filesize, count), i got a l...

How do I initialize a const std::pair ?

Let's say that I've got a : #include <utility> using namespace std; typedef pair<int, int> my_pair; how do I initialize a const my_pair ? ...

yet another STL tree question

Hello everyone, quite a funny question I have. I am working now on the HTML parser and I was using vector for all my input purposes which seemed quite fine and fast for creating tree. In another application I need to edit HTML structure and now inserting or reordering of the elements would be extremely painful using vector so I decid...

jQuery Variables as Key in Key:Pair CSS attributes

Is it possible to take something like: $("div").css({ "top": var1, "height": var2, etc. }); And turn it into: var dir = "top"; var length = "height"; $("div").css({ dir: var1, length: var2, etc. }); So far, the only way I can get it to work is by repeatedly declaring the lines separately, such as: $("div...

Accessing a nested pair

To take apart a pair, the following can be done boost::bind(&std::pair::second, _1); // returns the value of a pair What about using combinations of different containers, how can a nested pair be accessed? For example when I wanted to partition a vector into items contained in a supplemental map and items that where not contained in ...

C++ problem with std::pair and forward declarations

Hi! Unfortunately I still got a problem with my templated code from here: http://stackoverflow.com/questions/1911434/c-fancy-template-code-problem on line 49 in the file 'utility': error C2440: 'Initializing': cannot convert from 'const int' to 'IntersectionData *' error C2439: 'std::pair<_Ty1,_Ty2>::second': member could not be in...

c++ std::pair, std::vector & memcopy

Hi! is it safe to memcopy myvect.size()*sizeof(foo) bytes from the memoryadress of the first element of a std::vector<std::pair<T1, T2> > myvect into an array of struct foo{ T1 first; T2 second; } if the array is allocated with the same number of elements as the vector's size? thanks ...

C++ container/array/tuple consistent access interface

hello Is there, perhaps in boost, consistent element access semantics which works across containers? something along the lines of: element_of(std_pair).get<1>(); element_of(boost_tuple).get<0>(); element_of(pod_array).get<2>(); in principle i can write myself, but I would rather not reinvent the wheel.thanks ...

How can I store a pair of numbers in C++?

I'm trying to learn C++ and right now I'm writing a program that needs to output a list of pairs of integers. What is the best way to handle this? I don't have the boost library available on our linux computers at school, so I don't believe I can use boost::tuple. Any suggestions? ...

What is the difference between using a struct with two fields and a pair?

What is the difference regarding memory allocation and efficiency between using a struct with two fields and a pair? ...

No match for call to '(std::pair<unsigned int, unsigned int>) (unsigned int&, unsigned int)'

I don't know what's wrong with the follwing code, it should read numbers and put their value with the position together in a vector of pairs and then sort them and print out the positions. I removed the part with sort - i thought the problem was there, but i received an error on compilation again. #include <iostream> ...

c++ transform with pair go in Segmentation fault

This code works: class Test { public: Test(string name) : _name(name) {}; bool operator()() { cout << "hello " << _name << endl; return true; } string name() { return _name; } private: string _name; }; pair<string, bool> inline execute_test(Test* t) { return pair<string, bool>(t->name(), (*t)()); } int main() { vector<Test...

MYSQL KEY-VALUE PAIR Viability

Hi, I am new to mysql and I am looking for some answers to the follwoing questions: a) Can mysql community server can be leveraged for a key-value pair type database.?? b) Which mysql engine is best suited for a key-value pair type database ?? c) Is Mysql cluster a must for horizontal scaling of key-value based datastore or can i...

I have a KVP Key value pair Table, Need sql to make it relational structure...!

I have a KVP Table and the structure is ID, Key, Value and below are the sample values.... Table with values ID , Key, Value 1 , STATUS, TRUE 1, AGE GROUP, 10 1, TRAVEL, Y 2 , STATUS, FALSE 2, AGE GROUP, 20 2, TRAVEL, N I want these date to transform as below (Output) ID , STATUS, AGE GROUP, TRAVEL 1, TRUE , 10, Y 2, FALSE, 20, N ...