Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: fast maps and fast classes in general

  1. #1
    Junior Member
    Join Date
    Jan 2024
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default fast maps and fast classes in general

    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.

  2. #2
    Member Helium c2's Avatar
    Join Date
    Nov 2023
    Location
    Kekaha, Kaua'i
    Posts
    105
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: fast maps and fast classes in general

    Probably not going to work on all structures. The ME edition of Java is for the bluetooth and cell phone devices. But if you're going to use it on other devices like a car radio and place a map on there, this will be using a different system. Google map in car radios use Hi-Fi connections frequencies to connect the map and their servers. So when you're traveling down some highway, you pick up your location from that program. Class files.

Similar Threads

  1. One fast question
    By Jad_Asmar in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 23rd, 2013, 10:34 AM
  2. Fast Help please
    By Extremist252 in forum What's Wrong With My Code?
    Replies: 12
    Last Post: April 25th, 2013, 05:01 PM
  3. need HELP FAST PLEASE HELP ME
    By britben95 in forum Member Introductions
    Replies: 1
    Last Post: November 14th, 2011, 08:05 PM
  4. need help fast
    By coke32 in forum Loops & Control Statements
    Replies: 6
    Last Post: October 31st, 2011, 11:04 PM
  5. need help fast!!
    By nwollis in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 27th, 2010, 05:12 PM

Tags for this Thread