Questions tagged [map]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
246 views

Why is there no Hashmap in C++ like Java? [closed]

I know that the C++ standard library includes the ordered and the unordered map (std::map and std::unordered_map) containers, but why is there no hashmap available on C++? I was asked this questions ...
user avatar
-1 votes
1 answer
412 views

Why shouldn't I be using SQLITE instead of the INI format in all cases?

Backstory In an effort to store partial and full downloads to file in a clean manner, I had utilized QSettings which stores its key value pairs in the INI format in a single file. https://doc.qt.io/qt-...
user avatar
  • 3,319
4 votes
2 answers
257 views

Arrays vs Maps for listing items that have a unique id

I've been finding that for a lot of code I've been writing recently, it naively might look like this: Array approach: const options = [ { id: 'red', label: 'Red', data: '#f00' ...
user avatar
  • 2,463
3 votes
3 answers
402 views

Read large JSON file and return a subset for map

To some extent, this is a wide question, because I do not know in which direction I should move. I am using Polymaps to show markers on a map. The markers are static but the visualization depends on ...
user avatar
  • 141
2 votes
2 answers
176 views

Is registry pattern a valid use of global state?

For example, I want to convert json from server to generic object: Shape, as follow: { "type":"Circle", "radius":"3", }, { "type":"Rectangle", "width":"5", "height":"6", }, using ...
user avatar
-2 votes
1 answer
147 views

Map synchronization algorithm

Say I have two Map instances in JavaScript (or HashMap in Java, or Dictionary in C#), A and B. I want to synchronize B to A, so that B is a copy of A. I can't copy the reference and I don't want to ...
user avatar
  • 432
1 vote
4 answers
134 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 ...
user avatar
3 votes
0 answers
62 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 ...
user avatar
1 vote
2 answers
107 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":{ "...
user avatar
  • 5,582
3 votes
5 answers
7k 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. ...
user avatar
45 votes
1 answer
57k 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 ...
user avatar
0 votes
1 answer
328 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 ...
user avatar
  • 1
4 votes
4 answers
1k 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 (...
user avatar
25 votes
9 answers
7k 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 ...
user avatar
1 vote
1 answer
2k 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 ...
user avatar
3 votes
0 answers
415 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 ...
user avatar
1 vote
2 answers
976 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 ...
user avatar
  • 189
1 vote
4 answers
11k 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<>(); ...
user avatar
0 votes
1 answer
447 views

Javascript queue-like key-pair sorted collection

I'm looking for a collection that would suit my scenario: I will be inserting key-value pairs (both integers) of ID and timestamp. The ID must be unique. At some interval I will be checking that ...
user avatar
  • 143
1 vote
0 answers
203 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: ...
user avatar
5 votes
2 answers
301 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)); ...
user avatar
3 votes
2 answers
2k 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 ...
user avatar
  • 51
6 votes
3 answers
231 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 ...
user avatar
1 vote
3 answers
576 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":"...
user avatar
  • 121
0 votes
2 answers
834 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 ...
user avatar
  • 5,281
0 votes
1 answer
149 views

Mapping Lat & Long for daily history overview on Google Maps

So i have the following data for over a month ( an app that registers all i do) Lat Long On ( DateTime ) Now i am interested in creating a history on plotting the points on Google Maps, similar to ...
user avatar
  • 228
1 vote
1 answer
440 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 ...
user avatar
  • 115
3 votes
2 answers
182 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 ...
user avatar
  • 141
0 votes
2 answers
2k views

Implementing map with tail recursion

I am trying to solve this exercise. It is about reimplementing the map function in haskell for learning purpose. I found a solution which doesn't browse all the elements of the list (simple linked ...
user avatar
  • 103
1 vote
2 answers
126 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 ...
user avatar
  • 173
1 vote
1 answer
67 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 ...
user avatar
  • 111
5 votes
1 answer
3k 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 ...
user avatar
5 votes
1 answer
2k 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 ...
user avatar
15 votes
4 answers
33k 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 ...
user avatar
  • 315
-3 votes
2 answers
1k views

Integer Map Algorithm [closed]

For my project, I need to map integers so that inputting int X will output int Y where both X and Y are defined during runtime. I've used Dictionary<int,int> in .NET but its memory use is too ...
user avatar
  • 189
-3 votes
1 answer
385 views

DDD - map or object [closed]

What is correct by DDD - should I create map of two objects eg Map or should i use more meaningfull object that will contain this pair MoreMeaningfullName{Obj1, Obj2} ? If using first approach, I don'...
user avatar
21 votes
4 answers
14k 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 ...
user avatar
  • 319
2 votes
1 answer
961 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 ...
user avatar
  • 355
1 vote
4 answers
24k 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 #...
user avatar
1 vote
1 answer
98 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 ...
user avatar
1 vote
1 answer
289 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 ...
user avatar
  • 111
2 votes
1 answer
475 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 ...
user avatar
  • 21
4 votes
2 answers
4k 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 ...
user avatar
  • 19.2k
-3 votes
1 answer
29k views

Why does HashMap allow only one null key? [closed]

A HashMap allows only one null key. Is it because it allows only unique keys? Or is there another reason?
user avatar
  • 127
3 votes
2 answers
6k 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&...
user avatar
  • 14.6k
1 vote
1 answer
124 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 ...
user avatar
  • 391
3 votes
2 answers
10k 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 ...
user avatar
  • 276
25 votes
6 answers
16k 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)....
user avatar
  • 1,907
4 votes
2 answers
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 ...
user avatar
  • 5,680
2 votes
2 answers
159 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,...
user avatar