Questions tagged [map]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
25
votes
9answers
6k views

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 ...
20
votes
6answers
8k views

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)....
18
votes
4answers
11k views

“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 ...
9
votes
1answer
12k views

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 ...
8
votes
4answers
14k views

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 ...
8
votes
1answer
740 views

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 ...
6
votes
3answers
21k views

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,...
6
votes
1answer
189 views

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 ...
6
votes
3answers
202 views

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 ...
5
votes
2answers
14k views

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 ...
5
votes
2answers
230 views

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)); ...
5
votes
1answer
2k views

Storing pairs in a map

If I have a Pair class like this: class Pair<K, L>{ 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 ...
5
votes
2answers
677 views

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 ...
4
votes
4answers
548 views

Hash map without collision check

A few days ago I found a fun fact, that finding a collision of 256-bit hash using brute-force is physically impossible in solar system. That made me think, what would happen if we used a good (...
4
votes
2answers
2k views

How can “hash functions” be used to implement hash maps at all?

My understandment is that hash maps allow us to link, say, a string, to certain memory location. But if every string were to be linked to a unique place in memory it would need a huge block of empty ...
4
votes
1answer
2k views

(How can I / Am I allowed to) Use Google Maps as a Texture on an OpenGL object?

Note: I asked a very similar question on StackOverflow but did not get much attention, so was directed to http://programmers.stackexchange.com as licensing issues seem to have more interest here... I ...
3
votes
2answers
165 views

What is the most idiomatic way to iterate collection with different action for first element?

Sometimes we meet a situation where we should iterate (or map) over a collection, applying the same procedure (function) for all elements except the first one. The simplest example is finding the max ...
3
votes
5answers
1k views

Use POJO or Map when there is a finite number of known keys?

I have some set of data with key-value pairs, but there is only a finite and known set of keys, all of the key should always be present on that data, and they all have the same type for the value. ...
3
votes
2answers
853 views

A multi-processing approach to listing the occurrences of words in a text file

A classical problem: read the words from a text file and list the occurence of each unique word in the file. I solved the problem using a hash map, but how could the performance be improved? I ...
3
votes
2answers
5k views

How do I initialize a Scala map with more than 4 initial elements in Java?

For 4 or fewer elements, something like this works (or at least compiles): import scala.collection.immutable.Map; Map<String,String> HAI_MAP = new Map4<>("Hello", "World", ...
3
votes
1answer
1k views

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 ...
3
votes
1answer
273 views

For csv database extracts, how do map keys not create a dependency?

A lot of my work is done with .csv extracts (reports) from databases. As I have been programming in Clojure, I've received comments that relying on vector indexes creates dependencies. I understand ...
3
votes
1answer
993 views

Find the average speed for roads

I am working on a mobile application and I would like to ask you a question. Is there an API or a method to get/calculate the average speed that a car should have in a road. I am working on a GPS like ...
2
votes
2answers
3k views

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 ...
2
votes
2answers
8k views

Dataset with coordinates of borders of countries [closed]

I am creating an application that visually displays world regions, e.g. to place markers within an administrative region. Does a dataset exist with geometrical or geographical (long/lat) descriptions ...
2
votes
2answers
198 views

Best approach for saving highlighted areas on geographical map

I am designing an application that allow users to highlight areas of a geographical map using a tool that is like brush or a pen. The tool basically draw a circle with a single click and continue ...
2
votes
2answers
152 views

What can I do in order to inform users of potential errors in my software in order to minimize liability?

I'm an independent software developer that's spent the last few months creating software for viewing and searching map data. The software has some navigation functionality as well (mapping, directions,...
2
votes
2answers
2k views

Google Maps-based desktop application [closed]

I want to build a desktop application which has google maps embedded to it. This app should have a thread to read coordinate data online a usb microphone to use. This application will move the google ...
2
votes
1answer
526 views

Determine exact coordinates for a map image?

My brother suggested that I should write a web app that lets students create and print blank maps. A blank map is a map that contains country borders, waters etc. but no text labels. The first use ...
2
votes
1answer
232 views

How to find out if a tile is being covered by a polygon?

Given a (intersecting) polygon, I'd like find out which tiles are being covered by the polygon. Example: Details: Tiles are square, 1 unit wide/high The grid begins in (0,0) The corners of the ...
2
votes
0answers
50 views

java hashtable extending to support duplicates

I have to maintain an old application and have to extend some modules. There is an hashtable that is used for maintaining/holding some objects as representation of running (real) processes (don't see ...
2
votes
0answers
155 views

Self hosting map vector tiles for web application

I'm building a web application, which involves (currently) a REST backend and a frontend SPA. The backend is hosting massive geo-enabled data, and the frontend is displaying it on a mapbox map. I'm ...
1
vote
4answers
7k views

Is it possible to create instance of an Interface(e.g-Map Interface)?If it is then how?

In most Java code, I see people declare Java objects like this: Map<String, String> hashMap = new HashMap<>(); instead of: HashMap<String, String> hashMap = new HashMap<>(); ...
1
vote
2answers
118 views

Type of map for Try[T]

I was looking at the type of map for Try[T] in Scala, which is: def map[S](f: T=>S): Try[S] From Haskell, I am used to the type of map being: map :: (a->b)->[a]->[b] This seems very ...
1
vote
3answers
382 views

Is an assocative array ordered?

An associative array has many common similar names, hash, keymap, map, table, index. It's a map of keys and values but I cannot find a reputable definition of the phrase which tells me whether a map ...
1
vote
3answers
162 views

How to avoid having an object id as the key in a map and also inside the object itself?

I am using a JSON map to save objects (e.g. users) whose ids are the keys of the map but the object (user) itself also contains the id. JSON { "john":{ "username":"john", "age":30 }...
1
vote
4answers
20k views

Adding values to HashMap

I want to add values to a HashMap, which would be used by methods in the same class. I have two solutions: Adding all the values with static When the first method is called, add the values Solution #...
1
vote
2answers
94 views

When define locale text file, language key (eg:'en') or text key (eg:'WELCOME_MESSAGE'), which one should be the outermost key?

When define a locale text map, I can use: 1.locale key first { "en":{ "WELCOME_TO_USE_THIS_APP":"Welcome to use this app,...", "SOME_OTHER_TEXT":"fsdfsf..." }, "es":{ "...
1
vote
4answers
99 views

filter + map api design

I am writing a library call that will allow you to filter and map in the same iteration of the loop, this is async/callback style in Java. The problem of course is that for filtering we usually return ...
1
vote
1answer
1k views

MVP: Should a View have multiple Presenters?

Is it desirable (from an architectural standpoint) to have more than one Presenter communicating with a View? In my particular situation I have one presenter communicating with multiple views, and ...
1
vote
2answers
476 views

Map/store run time ID for objects

What I want to achieve: I need to obtain a run time (unique) id for "any object" (for classes either in java SE, classes I have created or classes provided by other third parties... any instance of a ...
1
vote
1answer
238 views

Memory usage on Creating a Travian like map and 441 Buttons on a page

I'm creating A Map like Travian on Xamarin forms My map is something like 5000*5000 The way I want to do that is to load part of the map (21*21) of the big map where the current village is the ...
1
vote
1answer
61 views

How to map collection of unique large numbers to an array?

I have a list of unique 8 byte random ids and new ids are generated often. Let's say that the total number of ids can become at most N (let's say 100,000). Now, I want to map each of these ids to a ...
1
vote
1answer
143 views

storing map template in database

I am working on an application that displays choropleth maps. These maps are of all different types, some display state by county, country by state/province, or world by country. How should I ...
1
vote
1answer
117 views

how to map controllers , models, and views as a todo list

Before starting on a current project I was wondering if there is a terminology for what I am planning on doing? Basically what I want to do is map out every object in layers such as all the ...
1
vote
1answer
805 views

Countour Mapping API

I have done some searching on Google, but haven't come up with much as of yet. I am wanting to take a set of point data, which I had previously been using to create weighted points for a heat map ...
1
vote
0answers
183 views

Data structure for fast bi-directional SHA-1 to SHA-3 mapping

What data structure would be best choice for fast and performant bidirectional SHA-1 to SHA-3 mapping? Or in other words fixed-length string to fixed-length string mapping? To be more precise: ...
1
vote
1answer
82 views

Reduce Operations on Distributed Databases

I would like to ask you about optimizing reduce operations (e.g. count) on multiple databases. Let's say there is a user table that is stored in various countries and sharding is made based on the ...
0
votes
2answers
557 views

Can hashtable be used for implementing multimap?

Is it correct that hashtables assume no key is shared between more than one records? In other words, can hashtables be used for implementing multimaps? When using a hashtable, can't multiple records ...
0
votes
1answer
177 views

How to avoid Global State with a world map?

This is a conceptual problem I'm having general difficulty with, and I'd like to look at an example that can hopefully help clarify this: using a map to represent an alterable game world. For ...