Skip to content
Advertisement

Tag: data-structures

Get keys from HashMap in Java

I have a Hashmap in Java like this: Then I fill it like this: How can I get the keys? Something like: team1.getKey() to return “United”. Answer A HashMap contains more than one key. You can use keySet() to get the set of all keys. will store 1 with key “foo” and 2 with key “bar”. To iterate over all

How do I instantiate a Queue object in java?

When I try: The compiler is giving me an error. Any help? Also, if I want to initialize a queue do I have to implement the methods of the queue? Answer A Queue is an interface, which means you cannot construct a Queue directly. The best option is to construct off a class that already implements the Queue interface, like

java: sparse bit vector [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 19 days ago. Improve this question Are there any well-known libraries in Java for sparse bit vectors?

Java implementation for Min-Max Heap?

Do you know of a popular library (Apache, Google, etc, collections) which has a reliable Java implementation for a min-max heap, that is a heap which allows to peek its minimum and maximum value in O(1) and to remove an element in O(log n)? Answer From Guava: MinMaxPriorityQueue.

Advertisement