Questions tagged [map]

62 questions
49
votes
1 answer

What is the use of DTO instead of Entity?

I am working on RCP application, I'm new to this application. Spring beans are used to write business logic to save/fetch entities. But, instead of sending entities directly to client we are converting to DTOs and populating client. While saving, we…
Naveen Kocherla
  • 613
  • 1
  • 6
  • 5
26
votes
9 answers

How to communicate that insertion order matters in a map?

I'm fetching a set of tuples from the database, and putting it into a map. The database query is costly. There is no obvious natural ordering of the elements in the map, but insertion order matters nonetheless. Sorting the map would be a heavy…
Vidar S. Ramdal
  • 434
  • 4
  • 11
25
votes
6 answers

Map of functions vs switch statement

I'm working on a project that processes requests, and there are two components to the request: the command and the parameters. The handler for each command is very simple (< 10 lines, often < 5). There are at least 20 commands, and likely will have…
beatgammit
  • 1,907
  • 3
  • 18
  • 25
21
votes
4 answers

"Use map instead of class to represent data" -Rich Hickey

In this video by Rich Hickey, the Clojure creator, he advises to use map to represent data instead of using a class to represent it, as done in Java. I don't understand how it can be better, since how can the API user know what the input keys are if…
Emil
  • 319
  • 1
  • 2
  • 7
15
votes
4 answers

What does mapping mean in programming?

I often hear things like: Mapping the classes Mapping the objects from the database Mapping the objects Mapping the elements of a list A mapper What does a mapper and the act of mapping something actually mean?
LuisDavis
  • 315
  • 1
  • 2
  • 7
11
votes
3 answers

sorting using a custom definition of ">" and "< " in python

suppose I have a custom function such as def greater(a, b): if (a % b) % 2 == 0: return 1 return 0 It defines how to compare two numbers and determine which is greater. In this case, if the function returns 1 a > b else, a < b. Can…
user5198
  • 221
  • 1
  • 2
  • 4
8
votes
1 answer

How do I efficiently store all OpenStreetMap data in an indexed way?

I have a PBF file that contains the following information about a country: Nodes, each with their own longitude, latitude and properties; used to store points in a 2D space. Ways, each with their properties, they are connected through nodes; used…
Tamara Wijsman
  • 8,259
  • 14
  • 58
  • 94
6
votes
3 answers

Are we "allowed" to use methods on JavaScript maps (the data type) and if so are there any new rules?

JavaScript maps (the data type, not the array method) seem set up to accept data (key/value pairs) but not necessarily methods. At least they're not advertised that way. However, we can put methods onto a map instance. Intriguingly, the keyword this…
Andrew Willems
  • 589
  • 2
  • 11
6
votes
1 answer

Multi-platform Map Application

I'm working on a web project (PHP, jQuery) which currently using Google Maps powering up the map functionality of the application, however we need to make it multi-platform like you can go to the dashboard and choose one from 5-10 map providers…
Mahdi
  • 1,983
  • 2
  • 15
  • 25
6
votes
2 answers

What is the advantage of using map datastructure?

I am a member of some online coding website and today when I submitted a solution in C++, I saw there were much better answers in C++ itself which took considerably less time. The solutions were open so I went on through some of them and found all…
user841923
  • 251
  • 1
  • 2
  • 10
5
votes
2 answers

Two "flavours" of undefined in JavaScript shown by trying to map them

Why does the 1st map method below treat element #2 as undefined but the 2nd map method does not? const a = [undefined,,42]; // Note the two consecutive commas. console.log(a.map(x=>x)); // -> [undefined, undefined,…
Andrew Willems
  • 589
  • 2
  • 11
5
votes
1 answer

Storing pairs in a map

If I have a Pair class like this: class Pair{ public final K a; public final L b; public Pair(K obj1, L obj2){this.a = obj1; this.b = obj2;} //... } I want to associate a Float with every pair of objects. They happen to be of…
user4205580
  • 423
  • 5
  • 11
5
votes
1 answer

Divide the world map into fixed sized blocks

I am developing an app where I need to divide the entire world map into fixed sized square blocks. For simplicity, think of it as a problem of dividing the google maps into a fixed sized block. I can choose any arbitrary point in the map and my app…
CuriousCoder
  • 153
  • 1
  • 5
5
votes
2 answers

Mapping a list of optional values to an optional list of values

I have encountered the following pattern while programming in Haskell (but the pattern could occur in any language supporting lists, option types, and mapping of a function over a list). I have types a and b and a function f :: a -> Maybe b Now I…
Giorgio
  • 19,486
  • 16
  • 84
  • 135
5
votes
2 answers

GIS-based data visualization and maintenance tool

Background Looking to leverage an existing GIS system for exploring organizational data. Architecture The following figure represents a high-level overview of the system's desired features: The most basic usage would be as follows: The user visits…
Dave Jarvis
  • 743
  • 6
  • 28
1
2 3 4 5