dictionary - Sorting maps Java -
i have hashmap of values, objects , keys, names of objects (names unique). objects contain lot of variables , sort map, using 1 of them. far there's no problem, thing values might same 2 or more objects, program overwrite them. in situation of 'collision' sort pairs has same key other key , on, until sort them in alphabetical order. i've tried create structure, it's not correct, cause it's sorting alphabetically no matter what.
sortedmap<integer, sortedmap<integer, sortedmap<integer, sortedmap<string, someclass>>>> mymap;
could please me bit? have figured out @ least close result? :) thanks!
edit:
sortedmap<string, abstracteventactivityclass> mapnameobject = new treemap<>(); sortedmap<integer, sortedmap<string, abstracteventactivityclass>> bydislikes = new treemap<>(collections.reverseorder()); sortedmap<integer, sortedmap<integer, sortedmap<string, abstracteventactivityclass>>> bylikes new treemap<>(collections.reverseorder()); sortedmap<integer, sortedmap<integer, sortedmap<integer, sortedmap<string, abstracteventactivityclass>>>> subscribers = new treemap<>(collections.reverseorder());
someclass:
public abstract class someclass { string name; userclass user; int likes, dislikes, nosubscribers; public someclass(string name, userclass user){ this.name = name; this.user = user; this.likes = 0; this.dislikes = 0; this.nosubscribers = 0; }
add object:
void addobject(string name, string description, userclass user){ someclass object = new someclass(name, user); this.mapnameobject.put(name, object); integer nodislikes = integer.valueof(object.dislikes); this.bydislikes.put(nodislikes, this.mapnameobject); integer nolikes = integer.valueof(object.likes); this.bylikes.put(nolikes, this.bydislikes); integer nosubs = integer.valueof(object.nosubscribers); this.subscribers.put(nosubs, this.bylikes); }
Comments
Post a Comment