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

Create Tree map in HTML using json object

I want to create Treemap using JSON object in which number of children item and and grand-child item will change. My json look like { "Root": "Parent", "Children": { "Children1": { "ChildName": "Child - 1", …
Aamir
  • 345
  • 4
  • 24
-1
votes
1 answer

How can I have a treeMap which is sorted by value keep being sorted when I change elements?

I have a map of string keys and int values, I to sort them, and keep them sorted when I change values. I tried using a treemap for the sorted pairs and a normal map for the unsorted paris so I can use it in the comparator, but after a one value…
Yovboy
  • 85
  • 7
-1
votes
1 answer

Why is my output "4 10 7" instead of "4 3 10 7" when i write the following code

I am trying to count the number of set bits are present in a number and arranging the numbers in the ascending order according to the count of the set bits. My input is : 1 4 3 4 7 10 Expected Output is: 4 3 10 7 My output is: 4 10 7 Why is it…
Mihir Mehta
  • 89
  • 1
  • 9
-1
votes
1 answer

Java Map/TreeMap: Modifying an existing entry without deleting entry

So I have a Map defined as Map data = new TreeMap(); and I am adding data as I loop through and read a text file. For most of the data, I'll add it and move on. However, there is data in the file that needs to…
Racehorse35
  • 121
  • 10
-1
votes
1 answer

Is TreeMap suitable for a input with million distinct records where sorting by value occurs regularly

I am planning to use a tree map in the below scenario. Given a list of users(around million distinct users) I need to keep track of the number of visits for each one of them. The users can visit the same site multiple times. It is a single…
Veda
  • 7
  • 8
-1
votes
1 answer

how to iterate through a treemap within a treemap java

hello i have this treemap : TreeMap words = new TreeMap(); the class info and node is this : public static class Info { int totalOccurrences; int maxTF ; ArrayList pointer; //ArrayList files; // document…
Pandelis
  • 17
  • 2
-1
votes
2 answers

How to use Map, TreeMap with List in Java?

How can I transform the following data result [a={x=0, y=43, z=57}, b={x=1, y=90, z=9}, c={x=1, y=83, z=16}] into {x=[0,1,1], y=[43,90,83], z=[57,9,16]} using Map and Treemap. Basically, I am iterating over a,b,c.. then while reading its values I…
Devz
  • 5
  • 1
  • 2
  • 9
-1
votes
1 answer

I want to make a treemap structure. And I want to find a previouse tree

class Fran { String name; int size; Fran(String name,int size) { this.name=name; this.size=size; } String getName() { return this.name; } int getSize() { return this.size; } } class Node { Fran fran; Node…
-1
votes
1 answer

Java Treemaps in descending order

I'm trying to count letters in a string in descending order. But my code only picks up some of my letters. Why is this? Code: import java.util.Iterator; import java.util.TreeMap; import java.util.TreeSet; public class CharacterCount { public…
Susan
  • 1
  • 2
-1
votes
2 answers

Java checking last element of LinkedList that is part of a TreeMap

I have a Java program which reads usernames and password histories from a text file and stores the info in a TreeMap. The user is then allowed to change passwords by selecting the username and then inputting their current password. The user info is…
vroom
  • 45
  • 1
  • 5
-1
votes
2 answers

How can I Cache the data I'm reading from a collection of text files in a directory using a TreeMap?

How can I Cache the data I'm reading from a collection of text files in a directory using a TreeMap? Currently my program reads the data from several text files in a directory and the saves that information in a text file called output.txt. I would…
FullNelson
  • 99
  • 2
  • 13
-1
votes
2 answers

how to insert in map (3 inputs) in java

I have an input that is given below. How can I insert these inputs in a map, HashMap preferrably. {1,"abc","a"} {200,"xyz","b"} {1,"ab","c"} {12,"fgh","d"} Integer being the key and remaining are values.
shyam karwa
  • 213
  • 1
  • 3
  • 8
-1
votes
2 answers

Putting data in TreeMap, causing duplicate entries

My first post on Stackoverflow so excuse me if I post it wrong... So I have an ArrayList with a lot of personal data (fetched from a service over json, parsed and mapped to a POJO Person). I'd like play with some statistics (draw graphs of…
Tomas Forslund
  • 139
  • 1
  • 6
-1
votes
1 answer

User-defined class objects in Java TreeMap

I have a collection (TreeMap), I want to print only one value from the Object im passing. Here is the code that I have being trying Student.java class Student { int rollno; String name; int age; Student(int…
supreeth v
  • 19
  • 8
-1
votes
1 answer

Sort a TreeMap with Class as values

I have a TreeMap with String keys and instances of a Class as values. I want to be able to sort on an object of the Class. I have gotten this far: public class StockTakeCompare { public static TreeMap sortByValues(final…
Mike6679
  • 5,547
  • 19
  • 63
  • 108
1 2 3
99
100