I'm having difficulty in using std::for_each and other algorithms with a multimap, and want to know if someone could help me developing a functor that could pass the appropriate parameter to the "generic" functions.
My specific problem with map/multimap is that their iterators evaluate to a std::pair instead of the contained value (I me...
Hi,
I know this questions has come up in various guises before, but this is slightly different.
I have a class which contains a std::map. Although I wish to use the map for other purposes inside the class, externally I want to expose an iterator adapter to just the values inside the map (ie the second item in the std::pair).
For examp...
Hi,
I would like to have some points defined in the map and would like to join the 2 points by clicking on them. Basically, the functionality is to identify the locations in the map and connect them by a single line. For some reason, I am not able to use google map API and would like to achieve this using JavaScript.
Thanks in advance...
I have some questions on using std::map:
Is using an enum as the key in std::map a good practice? Consider the following code: enum Shape{
Circle,
Rectangle
};
int main(int argc, char* argv[])
{
std::map strMap;
// strMap.insert(Shape::Circle,"Circle"); // This will not compile
strMap[Shape::Circle] = "Circle"; ...
HI,
I don't like posting compile problems, but I really can't figure this one out. Using this code:
#include <map>
#include <boost/iterator/transform_iterator.hpp>
using namespace std;
template <typename K, typename V>
struct get_value
{
const V& operator ()(std::pair<K, V> const& p) { return p.second; }
};
class test
{
type...
Hey there,
I'm having a little issue...I setup a rails application that is to serve a german website. To make use of Rails' internal pluralization features, I kept all my models in english (e.g. the model "JobDescription").
Now, if I call "http://mysite.com/job_descriptions/", I get all my job_descriptions....so far, so good. Because I ...
I have a problem with custom ItemizedOverlay on the MapView in Android.
What I've done: Very simple offspring of ItemizedOverlay class that only wraps my own type of items and uses ItemizedOverlay for all the hard work.
What works: Nearly everything - items are drawn properly, I can tap them etc.
The problem: If I drag the map in the ...
I have a std::map like this:
map<wstring,int> Scores;
It stores names of players and scores. When someone gets a score I would simply do:
Scores[wstrPlayerName]++;
When there is no element in the map with the key wstrPlayerName it will create one, but does it initialize to zero or null before the increment or is it left undefined?
...
std::map<std::string, std::string> myMap;
std::map<std::string, std::string>::iterator i = m_myMap.find(some_key_string);
if(i == m_imagesMap.end())
return NULL;
string *p = &i->first;
Is the last line valid?
I want to store this pointer p somewhere else, will it be valid for the whole program life?
But what will happen if I ad...
I have a map defined like this
std::map<some_key_type, std::string::iterator> mIteratorMap;
And a huge string named "mHugeString". Then I walk trough the string collecting iterators like this:
std::string::iterator It=mHugeString.begin();
std::string::iterator EndIt=mHugeString.end();
for(;It!=EndIt;++It){
...defining a key element...
I am doing a report on the various C++ dictionary implementations (map, dictionary, vectors etc).
The results for insertions using a std::map illustrate that that the performance is O(log n). There are also consistent spikes in the performance. I am not 100% sure what's causing this; I think they are caused by memory allocation but I ...
Given:
Object nestKey;
Object nestedKey;
Object nestedValue;
Map<T,Map<T,T>> nest;
Map<T,T> nested;
How is a mapping added to nested where:
nest.containsKey(nestKey) == true;
?
Or is there an existing library of collections that would be more effective?
...
I want to get all the values associated with a key in Map.
For e.g,
Map tempMap = new HashMap();
tempMap.put("1","X");
tempMap.put("2","Y");
tempMap.put("3","Z");
tempMap.put("1","ABC");
tempMap.put("2","RR");
tempMap.put("1","RT");
How to retrieve all the values associated with key 1 ?
...
It is often useful to implement algorithms using nested array operations. For example, to find the number of words in a list that start with each given character, you might do something like this in Python:
>>> a = ["foo","bar","baz"]
>>> map(lambda c: len(filter(lambda w: w.startswith(c), a)), ('a','b','c','d','e','f'))
[0, 2, 0, 0, 0,...
Ok. I'm not asking for a plssendcodezkthx. But I am somewhat new to FP and I'm trying to figure out how to do this, because I know the code I have won't accomplish what I'd like to achieve. So all arguments about optimization aside, here is my code Then I'll explain.
let moveBoids boids =
boids |> List.map (fun(boid) ->
let...
I'd like to initialize a map - object "id" with identities from 0 to n-1, i.e.
id[0] = 0
id[1] = 1
.
.
id[n-1] = n-1
Is there a simple way - a one-liner, a method inside the map-object, simply something really simple - that does that?
...
Hello! ... and thanks for reading...
I'm still learning the ropes so please be forgiving... ;-)
I am writing a function that meshes a solid in space. The mesh is done by using objects of a "Node" class and each node is represented by:
int id
double p
double r
Initially I thought that a map would be the way to go: with a map I can m...
I have a few maps with certain areas (zones) which I'll want to capture in KML. Within those areas I need to pinpoint addresses.
How do I save those maps with its values as efficient as possible to query them later?
...
Is it OK to pass to function a reference to the value of map element, and to modify it there?
foo(string & s)
{
s = "xyz";
}
map<int, string> m;
m[1] = "abc";
foo(m[1]); // <-- Is it ok? Will m[1] be "xyz" after this call?
Thank you.
...
I want to do the following:
Define a map between a string and any kind of object (may be a list, integer - anything).
The keys to the map can be as follow (the values are, again, not important):
"AAA/123" ==> 1
"AAA/" ==> 2
"BBB/" ==> 3
"CCC/*" ==> 4
"CCC/123" ==> 5
Now, the trick is I want to find the right values given the following st...