map

Can a STL map be used with keys of varying sizes

Can a STL map be used for keys of varying sizes? I don't have code for this. I'm still trying to figure out if this can be done and hence my question. (I'm the type that can spend too much time on an impossible problem. I'm hoping to learn from your wisdom). I am working on a look up table that essentially has two keys. A numeric type ...

Implementation of java.util.Map using insertion order as order

The JDK documentation on java.util.Map states The order of a map is defined as the order in which the iterators on the map's collection views return their elements. Some map implementations, like the TreeMap class, make specific guarantees as to their order; others, like the HashMap class, do not. And the documentation...

How to keep the sequence file created by map in hadoop

Hi I am using hadoop and working with a map task that creates files that I want to keep, currently I am passing these files through the collector to the reduce task. The reduce task then passes these files on to its collector, this allows me to retain the files. My question is how do I reliably and efficiently keep the files created by...

Clojure Parallel Mapping and Infinite Sequences

Let's say I define the sequence of all natural numbers in the following way: (def naturals (iterate inc 0)) I also define a function mapping the naturals to nil that takes a while to compute like so: (defn hard-comp [_] (Thread/sleep 500)) Note the computation time to evaulate the following s-expressions as measured by clojure.core...

Convert lat / lon to pixel locations

I've got a map (Mercator), and the coordinates of the 4 corners of the map. I need to come up with something so I can convert given coordinates to corresponding points on the map. I can't use google or anything of the sort, which is why I'm needing to do this in the first place. The languages I can use are either going to be PHP or ...

Displaying a MapView with a SubAcivity

Hi, I have a main activity. its main.xml generates a view that holds a slider, which on click, reveles some area for conent. In this area I want to display a map. so I need a second activity. I am able to call the sub activity but I want it to be displayed in the area of the slider of the main.xml, however the map has its own mapview.xm...

what C++ map mean?

I have the following C++ map example code: map<string,string> &weight2price .... weight = ... price = ... if(weight2price.find(weight) == weight2price.end()) weight2price[weight] = price; could anyone tell me what it means by if(weight2price.find(weight) == weight2price.end()) ...

Map kind of behavior needed

In map we have key, value pair.If we try to put same key in map 2 times it will produce a error.Now i want similar kind of behavior for value too.In short when i put a new key,value into the map both key and value should be unique, or else it should through an exception, How can i achive this? ...

Does Java's LinkedHashMap maintain the order of keys?

When LinkedHashMap.keySet() is called, will the order of the Set returned be the same as the order the keys were added in? ...

Nested map<K,V>'s instead of List< Object[] > as return values. Any problems?

The situation occurs when getting some data from the database to compose a report that is grouped by various fields. For example, grouped by month, then type and then actual vs prediction. The database query returns simply a List< Object[] >. But it is boring to directly render it as an HTML table. What I do is to group the data inside a...

key comparisons in c++ map not working

Hi, I have created a map with ClassExpression as the key and std::string as the value. The key comparator is given below class ClassExpressionComparator { public: bool operator()(const ClassExpression& lhs, const ClassExpression& rhs) const { return ((lhs.quantifier == rhs.quantifier) && (lhs.p...

How to implement an end in a map?

I'm implementing map for an excersise and I'm at the point where I would have to iterate over it (done and working) but the problem is that I don't know how to implement a last element (presumably an empty link). I was thinking that I would attach some special kind of link (descendant of base link) which would then be attached to the las...

Is it possible to add Puerto Rico to existing US map

Is it possible to add Puerto Rico to an existing US map (Dundas Map control) that is already configured? I inherited a Visual Studio 2008 project with US map already configured, and now I need to add Puerto Rico to this map. It seems that you can't select a specific country and add to an existing map. Even more, I can't even find Puerto ...

Merging XML files

Hello! How do I merge multiple XML files, without having redundant data? I have a project using OpenStreetMap, and the data dumps are in XML format. But becuase I plan to divide my target area in the map, then some nodes(points in the map) will be repeated in the XML files. I want to merge all that XML files, and prevent redundant data i...

Need a mix of Delayed and Map

I have an application without a save button; saving happens automatically in the background. As the user works with the app, tasks are created and put into a queue for execution. Some of them are delayed, for example, when you start typing, I wait 200ms before I update the corresponding value in the database. To make this more simple to...

How do I use the 'map' method in an ActiveRecord class method?

Not sure on my Ruby syntax here. I want to define a method that I can call like this: client.invoices.average_turnaround. So my average_turnaround method needs to work with a collection of ActiveRecord objects. Here's my code thus far: class Invoice < ActiveRecord::Base ... def self.average_turnaround return self.map(&:turnaro...

Get values for keys within a range in Java

Suppose I have a map in Java which looks like this: { 39:"39 to 41", 41:"41 to 43", 43:"43 to 45", 45:">=45" } If the keys are in sorted order(either using treemap or linkedhashmap).Now if i try to get a value which is >=39 and <41.Then I should get the String "39 to 41".How do I do this efficiently? ...

STL containers , remove object from two containers

Hello . Suppose I have two containers , holding pointers to objects ,which share some of their elements . from http://www.cplusplus.com/reference/stl/list/erase/ it says that : This effectively reduces the list size by the number of elements removed, calling each element's destructor before. How can I remove an object from b...

Write Git commit message in new Vim window, then commit all within Vim

I have these Vim mappings for Git. Most of the commands below work, but the last one, gm, doesn't work at all. I want to open a new Vim (preferrably with my git commit message template already loaded, as per the default terminal behavior), edit and save my message, then commit. Any ideas for another way to approach this? " git shortc...

Launch google map from mobile Browser

I was using "google local" on NOKIA 6800 browser the search result page had a link "view on map?" Clicking on it launched Google Maps application, and map centered on the location of the search result. how it is done?? Javascript ?? I have seen similar behavior in Iphone ...