Questions tagged [treemap]

An implementation of a mapping (dictionary) using a tree. This tag is also used for treemapping, an information visualization method for displaying hierarchical data with nested rectangles.

A map implemented as a tree

A map (also called dictionary or associative array) can be represented as a tree, typically a binary search tree. This tag can be used for such implementations, especially the TreeMap class in Java.

Treemapping visualisation technique

A treemap is a method for displaying tree-structured data in two dimensions. Each element is represented as a rectangle, with the children of a tree displayed as sub-rectangles inside their parent's rectangle.

Treemap example http://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Tree_Map.png/305px-Tree_Map.png

1412 questions
19
votes
4 answers

Migrating Java TreeMap code to Scala?

I am migrating my Java code base to pure Scala and I am stuck on this one piece of code. I have an implementation of an IntervalMap i.e. a data structures that let's you efficiently map ranges [from,to] to values where the set, delete and get…
pathikrit
  • 29,060
  • 33
  • 127
  • 206
19
votes
6 answers

How to get key and value of a TreeMap at particular index

I have a TreeMap with a set of 'Key and Value' pairs. How can I get both Key and Value at a particular Index of the TreeMap? EDIT : @TO-ALL : Thanks. But I know how to implement it by using an extra ArrayList. I just thought is there any way to…
Dileep Perla
  • 1,705
  • 7
  • 31
  • 53
18
votes
5 answers

How to Print treemap in reverse order

In my assignment we are read from a file the text: To be, or not to be: that is the question: Whether 'tis nobler in the mind to suffer then count the times each has occured. I've been able to print this map unsorted, then I was able to make a…
IC2D
  • 423
  • 3
  • 11
  • 20
18
votes
4 answers

Java TreeMap equivalent in C#?

Most places I've consulted say to use SortedList, but the problem is that the program I'm porting actually uses duplicate keys (differentiated by order), which is permissible with TreeMap, but not SortedList. Any advice?
user58817
17
votes
3 answers

Using java.util.Map in h:dataTable

I need to display Map using . My backing bean has a Map property as below: public class Bean { private Map map; // +getter @PostConstruct public void init() { map = new TreeMap(); …
JPS
  • 2,448
  • 5
  • 26
  • 51
17
votes
4 answers

TreeMap how does it sort

How does the TreeMap sort? say for example you have the following map: TreeMap treemap = new TreeMap<>(); treemap.put("lol", 1); treemap.put("Marc", 2); treemap.put("Jesper", 3); Iterator ittwo = treemap.entrySet().iterator(); …
Marc Rasmussen
  • 17,383
  • 66
  • 172
  • 305
16
votes
3 answers

how to encode this data to parent / children structure in JSON

I am working with d3.js to visualise families of animals (organisms) (up to 4000 at a time) as a tree graph, though the data source could just as well be a directory listing, or list of namespaced objects. my data looks like: json = { …
johowie
  • 2,245
  • 6
  • 22
  • 40
15
votes
7 answers

How would I print all values in a TreeMap?

I have a project that I'm working on for my Java class (obviously) and I must have missed the lecture on how to interact with TreeMaps. I have no idea what I'm doing with this part and I'm not finding a lot of help from Google. For the first case…
Lish
  • 197
  • 2
  • 2
  • 10
15
votes
4 answers

d3.nest() key and values conversion to name and children

I am working on creating a Treemap from a csv file. The data in the csv file is hierarchical, as a result I used d3.nest(). However, the resulting JSON is in the form of {key:"United States", values:[...]}. The zoom-able treemap requires hierarchy…
user2457956
  • 193
  • 1
  • 6
15
votes
9 answers

How to sort a treemap based on its values?

How can I sort a treemap using its values rather than the key?
Click Upvote
  • 235,452
  • 251
  • 553
  • 736
14
votes
2 answers

TreeMap - Search Time Complexity

What is the time complexity of a get() and put() in a TreeMap? Is the implementation same as a Red-Black Tree?
java_geek
  • 15,768
  • 29
  • 82
  • 105
13
votes
5 answers

Avoiding TreeMap ConcurrentModificationException?

I am calling function that returns TreeMap instance, and in the calling code I wanted to modify the TreeMap. However, I am getting a ConcurrentModificationException. Here is my code: public Map function1() { Map
Nagappa L M
  • 1,240
  • 3
  • 16
  • 28
12
votes
3 answers

Java putting Hashmap into Treemap

I am currently reading 2 million lines from a textfile as asked in the previous question Java Fastest way to read through text file with 2 million lines Now I store these information into HashMap and I want to sort it via TreeMap because I want to…
BeyondProgrammer
  • 823
  • 2
  • 14
  • 31
12
votes
2 answers

Time complexity of TreeMap operations- subMap, headMap, tailMap

Does anyone know the time complexity of the operations of TreeMap like - subMap, headMap. tailMap. The time complexity of operations like get, put is O(logn). But the javadoc doesnt say much about the complexity for the above operations. The worst…
agaase
  • 1,362
  • 13
  • 21
12
votes
1 answer

Creating a custom d3 layout

I need to create a custom d3 layout that is somewhat close to a treemap but in a triangular style. Here's a screenshot so that you can understand: Pyramid layout As you can see, it works pretty neat and fits my need. To code it, i've based the code…
user1804450
  • 121
  • 1
  • 3
1
2
3
94 95