class MyMap{ // int -> long map public long map[]; public int ind[]; private int count; public MyMap(){ this.map = new long[30000000]; this.ind = new int[30000000]; } public void put(int index, long data){ this.map[index]=data; this.ind[count]=index; count++; } public long get(int index) { return this.map[ind[index]]; } public long fetch(int index) { return this.map[index] ; } public long fetchi(int index){ return this.ind[index] ; } }
Hi all. Just a general thing I've found with programming with maps ( key -> value ) structures/classes.
I find that the above (my) definition of a mapping struct is much faster than the 'official' mapping struct in every programming language i've used.
I like to use maps so I often find I use my fast map definition.
Just wondering if this is the general theory behind the speed, so can be true for all structures:
because the official structs/classes are so heavily weighed down with tons of methods, any bare bones def is going to be much faster.
In that case, are these bare-bones defs a common meme among programmers?
Once I have my simple custom map def working, its easy to add new methods when I need them.