Quantcast
Channel: Initializing a HashMap with default values? - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Initializing a HashMap with default values?

$
0
0

I'm implementing the A* search algorithm given here, https://en.wikipedia.org/wiki/A*_search_algorithm

This line indicates we need to initiliaze a map with the default values of INFINITY,

gScore := map with default value of Infinity

So I tried that here,

Map<State, Double> gScore = new HashMap<State, Double>(Double.POSITIVE_INFINITY);

This does not work however the following does;

Map<State, Double> gScore = new HashMap<State, Double>((int) Double.POSITIVE_INFINITY);

I'm wondering why, and what impact (if any) it will have on my implementation.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images