java - ConcurrentSkipListMap and multi-column comparator -


i have following class keyobj

public class keyobject {     private byte[] p1;     private byte[] p2;     private byte[] p3; } 

i want put object of class concurrentskiplistmap confuse on how write comparator range queries possible. i.e. if p1 given return me p2 , p3. below

keyobject fromkey = new keyobject(k1.p1, p2_min_value, p3_min_value); keyobject tokey = new keyobject(k2.p1, p2_max_value, p3_max_value); concurrentnavigablemap<keyobject, object> subview = table.submap(fromkey, tokey); (concurrentskiplistmap.entry<keyobject, object> entry : subview.entryset()) { ... } 

or

keyobject fromkey = new keyobject(k1.p1, k1.p2, p3_min_value); keyobject tokey = new keyobject(k2.p2, k2.p2, p3_max_value); concurrentnavigablemap<keyobject, object> subview = table.submap(fromkey, tokey); (concurrentskiplistmap.entry<keyobject, object> entry : subview.entryset()) { ... } 

use comparable or comparator interfaces , define methods compareto or compare in them in way want them behave.

ajay


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -