map

Does .NET have a Dictionary implementation that is equivalent to Java's ConcurrentHashMap?

To recap for those .NET gurus who might not know the Java API: ConcurrentHashMap in Java has atomic methods (i.e. require no external locking) for common Map modification operations such as: putIfAbsent(K key, V value) remove(Object key, Object value) replace(K key, V value) It also allows iteration over the keyset without locking (i...

Geographical Data Visualization in a Web Application

I've got a request to implement a visualization service for geographical related data. I have a list of Italian ZIP Codes (they are called CAP in Italian). I've already found a table which maps these ZIP codes to geographical coordinates (lat/long). So, the data I have to visualize as map is structured the following way: ZIPcode Latit...

Which data structure would you use: TreeMap or HashMap? (Java)

Description | A Java program to read a text file and print each of the unique words in alphabetical order together with the number of times the word occurs in the text. The program should declare a variable of type Map<String, Integer> to store the words and corresponding frequency of occurrence. Which concrete type, though? TreeMap<St...

F#: How do I use Map with a Collection (like Regex Matches)?

Soo... F# no longer has IEnumerable.map_with_type... which is the way people were mapping over collections. How do I do that now? let urlPat = "href\\s*=\\s*(?:(?:\\\"(?<url>[^\\\"]*)\\\")|(?<url>[^\\s]* ))";; let urlRegex = new Regex(urlPat) let matches = urlRegex.Matches(http("http://www.google.com")) let matchToUrl (urlMatch : ...

In STL maps, is it better to use map::insert than []?

A while ago, I had a discussion with a colleague about how to insert values in STL maps. I preferred map[key] = value; because it feels natural and is clear to read whereas he preferred map.insert(std::make_pair(key, value)) I just asked him and neither of us can remember the reason why insert is better, but I am sure it was not just a...

Parallelizing the "Reduce" in "MapReduce"

I understand how Map is easily parallelizable - each computer/CPU can just operate on a small portion of the array. Is Reduce/foldl parallelizable? It seems like each computation depends on the previous one. Is it just parallelizable for certain types of functions? ...

Garbage Collecting objects which keep track of their own instances in an internal Map

In the constructor of my class, I map the current object (this), along with its key (a string entered as a parameter in the constructor) into a static LinkedHashMap so I can reference the object by the string anywhere I might need it later. Here's the code (if it helps): public class DataEntry { /** Internal global list of DataEntr...

What does Java use to determine if a key is a duplicate in a Map?

My first instinct is to say each key is an object, and has a hash code, which is what is used to determine if a duplicate is being inserted. However, I can't find anything to back that up for sure. Can someone provide a link that says that, or provide the real answer here? Thanks! ...

Simplest way of mapping an index to a string in C++

Requirements: Must be able to use C strings as well as C++ strings Fast No maps No templates No direct lookup, i.e. index might be out of bounds. Index is not consecutive Enums and strings contained in one header file Only instantiate what you use. This is what I have come up with so far: - test.hh - // Generic mapper // // The id...

How can I execute a given function on every element of a complicated data structure in Perl?

I want to decode all the HTML entities in a complicated data structure. Basically I'm looking for a "super map()" function. Here's what I have so far: sub _html_decode { my $self = shift; my $ref = shift; if (ref($ref) eq "HASH") { $self->_html_decode_hash($ref) } if (ref($ref) eq "ARRAY") { $self->_...

Where do theses values come from in this haskell function?

I my last question about haskell, the answer provided gave me another doubt... Instead of using the somewhat complex function in my other question, here's a simpler example: sumAll :: [(Int,Int)] -> Int sumAll xs = foldr (+) 0 (map f xs) where f (x,y) = x+y Calling sumAll [(1,1),(2,2),(3,3)] the output will be 12. What I don't unde...

Generate google map based on UK postcode

Hi, Is it possible to do a google map lookup using the google maps API from a UK postcode? I know you can search by UK postcode on their website, but this converts to lat / long. I don't have access to the PAF database to be able to convert to long / lat. An example: Users have an item to sell. One of the details of that item is a pos...

What is a good api for mapping gps coordinates in c#?

I have a project that has a list of gps coordinates. I would like to find a way to make a simple map of those coordinates (possibly just one at a time). The map should have basic street info. This part of our project is pretty simple so I don't think it needs to be an exceptionally feature rich product. This also means it shouldn't be r...

Inspecting standard container (std::map) contents with gdb

Supposing to have something like this: #include <map> int main(){ std::map<int,int> m; m[1] = 2; m[2] = 4; return 0; } I would like to be able to inspect the contents of the map running the program from gdb. If I try using the subscript operator I get: (gdb) p m[1] Attempt to take address of value not located in mem...

Ocaml List: Implement append and map functions

Hi! I'm currently trying to extend a friend's OCaml program. It's a huge collection of functions needed for some data analysis.. Since I'm not really an OCaml crack I'm currently stuck on a (for me) strange List implementation: type 'a cell = Nil | Cons of ('a * 'a llist) and 'a llist = (unit -> 'a cell);; I've figured out that t...

What happens to an STL iterator after erasing it in VS, UNIX/Linux?

Please consider the following scenario: map(T,S*) //Forward decleration map(T, S*) T2pS = GetMap(); for(map(T, S*)::iterator it = T2pS.begin(); it != T2pS.end(); ++it) { if(it->second != NULL) { delete it->second; it->second = NULL; } T2pS.erase(it); //In VS2005, after the erase, we will crash on ...

How do I efficiently transform a series of strings in powershell?

Suppose I have a large number of strings formatted something like: <tag>blah blahXXXXXblah blah</tag> I want to transform these strings into something like: blah blahZZZZZblah blah on a powershell command line. All instances of XXXXX get replaced by ZZZZZ in the transformation and the outer tags are stripped out. It isn't well-fo...

How do I create a Lua Table in C++, and pass it to a Lua function?

Hi, In C++, I have a map<string, string>, containing an unknown number of entries. How can I pass this to a Lua function, so that the Lua function can use the data as a table? Hugo ...

Why does STL map core dump on find?

So, I have this situation where I need to see if an object is in my stl map. If it isn't, I am going to add it. char symbolName[] = { 'H', 'e', 'l', 'l', 'o', '\0' }; map<string,TheObject> theMap; if (theMap.find(symbolName)==theMap.end()) { TheObject theObject(symbolName); theMap.insert(pair<string, TheObject>(symbolName, ...

How can I make a country plot in Sage/Maxima?

I heard today that Maxima can do the country plot by contour_plot in Sage. I tried the following unsuccessfully to import Maxima: from Maxima import contour_plot I would like to make a similar map as here. ...