EsotericSoftware / kryonet

TCP/UDP client/server library for Java, based on Kryo
BSD 3-Clause "New" or "Revised" License
1.82k stars 419 forks source link

Wrong IntMap size after adding multipl entries with key 0 #65

Closed vprotasov closed 10 years ago

vprotasov commented 10 years ago
public static void main(String[] args) {
    IntMap map = new IntMap();

    map.put(0, "");
    map.put(0, "");
    map.put(0, "");

    System.out.println("map size="+map.size);
    System.out.println("map="+map);
}

map size=3 map=[0=]

NathanSweet commented 10 years ago

In a map its size is equal to the number of unique keys.

NathanSweet commented 10 years ago

Eh I guess you are trying to report that the size is 3 when it should be zero. At any rate, this is a Kryo bug so it is fixed there. https://github.com/EsotericSoftware/kryo/commit/2d398bce497c4fb73aa46d5e4eaa8dcfaf4492ea

vprotasov commented 10 years ago

Thanks, I would expect size = 1, as key with value 0 is present 1 time.

NathanSweet commented 10 years ago

Yep, I just didn't read your code closely at first. :) Thanks!