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

1568 questions
-1
votes
1 answer

Else master will never be excuted in successor() in treemap

I'm learning sourcecode of remove() in treemap. But there is something i can't understand. //....................ignore major codes,left these private void deleteEntry(Entry p) { if (p.left != null && p.right != null) { Entry
hb t
  • 1
-1
votes
1 answer

Array of JSON to Tree-structure JSON of Array

I want to write the function which can take an array of JSON to tree-structure JSON of array. I have an Array of JSON like this: var rawData = [{ "dimension": ["a", "c", "f"], "metric": [26] }, { "dimension": ["a", "b", "e"], …
Ketul dave
  • 21
  • 2
-1
votes
5 answers

Why LinkedHashMap can't sort HashMap while TreeMap can?

I'm trying to sort HashMap's output using LinkedHashMapand TreeMap. When I use TreeMap to sort out HashMap it works like a charm. Map hMap = new HashMap(); hMap.put(40, "d"); hMap.put(10,…
Dil.
  • 1,996
  • 7
  • 41
  • 68
-1
votes
2 answers

How to write TreeMap into a .txt file?

I'm new to this forum, so please let me know if I'm not posting this in the correct place. I've been trying to write a simple program that creates a list of contacts and sorts them by last names. However, I'm having some difficulty saving this…
user10189809
-1
votes
2 answers

Java use byte[] as key in a Map

I am having a little bit of struggle with Java maps. I want to have a map which takes a byte[] as a key and returns a custom object as the value. First I tried using hash maps, but because I used to different arrays, but with the same values, it…
Pilikio
  • 302
  • 4
  • 13
-1
votes
2 answers

Losing data when transferring data from TreeMap to TreeSet.

I have a TreeMap like so. // Create a map of word and their counts. // Put them in TreeMap so that they are naturally sorted by the words Map wordCount = new TreeMap(); wordCount.put("but",…
kaun jovi
  • 555
  • 1
  • 5
  • 21
-1
votes
1 answer

TreeMap ClassCastException

Cannot figure out where the String casting is coming from that is causing this ClassCastException. I've cleared out the map so that it only holds a single entry (115,1563) and I ensured both parameters were integers. First I read from a file and…
-1
votes
1 answer

creat treemap for binary-tree in racket

I need help in racket pl Using this BINTREE definition, write a (higher-order) function called treemap that takes in a numeric function f and a binary tree, and returns a tree with the same shape but using f(n) for values in its leaves. For example,…
learn
  • 13
  • 1
  • 3
-1
votes
1 answer

Creating an (k)Integer and (v)Set TreeMap from a list in Java

My aim is to fill a TreeMap with keys as Integer values, and values as a set of elements from a list. For example say I have a list like: 1 big 345, 1 small 223, 2 big 312, 1 small 116 I'd like the keys of the TreeMap to be the first number, and…
Sean2148
  • 365
  • 1
  • 3
  • 13
-1
votes
2 answers

How to retrieve List object stored in TreeMap?

I have a list of objects that I needed to sort by category and also alphabetically. My idea was to take my ArrayList, convert it to a HashMap so that I could use a key to organize my data by category, and then createe a treemap to naturally…
portfoliobuilder
  • 7,556
  • 14
  • 76
  • 136
-1
votes
1 answer

TreeMap allowing null key

I am searching for a TreeMap that allows one null key. What I need is a sorted Map where I can insert one null key representing the default value: If the map does not contain the specified key, the value associated with the null key…
-1
votes
1 answer

TreeMap returns null while using map.get(Object)

TreeMap prints value as null while fetching value using get method whereas it is working fine with HashMap(). Please find below the sample code and provide inputs to this. It's working fine for Hashmap as it uses equals()/hashcode() methods whereas…
GaurZilla
  • 371
  • 4
  • 13
-1
votes
2 answers

Concat multiple arraylist and put in tree map

Below is the code i am facing problem with. I have a List attribute list which gets data on every iteration (m=0,m=1 etc) Every time data is different. What i want to do is that I should somehow concatenate data on these iterations. So that whole…
Aby
  • 1
  • 3
-1
votes
4 answers

How to sort TreeMap based on keys where keys are alpha numeric , but we need to sort based on available numbers only?

I have a TreeMap which needs to be sorted based on keys. Which is default property of TreeMap. But in my case I am not able to figure out the Comparator. Following is my Code. public class Test { public static void main(String[] args) { …
Arpan Das
  • 1,015
  • 3
  • 24
  • 57
-1
votes
3 answers

How much time will a TreeMap take?

I am using a TreeMap with its keys as String and values as a List of Custom objects. Something like this: Map> map = new TreeMap>(); I know that insert and get operations on a TreeMap have O(log…
Aman
  • 425
  • 1
  • 5
  • 22
1 2 3
99
100