Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 146709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:39:06+00:00 2026-05-11T08:39:06+00:00

I’ve looked in the usual places (apache commons, google) and not been able to

  • 0

I’ve looked in the usual places (apache commons, google) and not been able to find one …

It should be opensource.

Pretty much looking for one based on a linked list. The use case is 10’000’s of maps, with not necessarily many values in. It does not need to scale up, as i can convert it when it gets too big.

Some numbers, sizes using some calculated jvm values (8bytes/java.lang.Object, 4bytes/ref) the HashMap is about 100+32n bytes, the theoretical best is 12+20*n. <– I want that, for small n.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:39:07+00:00Added an answer on May 11, 2026 at 8:39 am

    Ok, implemented it myself in the end. I did a speed comparison, and found when compared to a HashMap that it was still slightly faster with 4 entries, but slower with 5 or more. I did the tests with a longish list of keys that I tried to give a similar makeup as a list of random english words.

    import java.util.*;  // PUBLIC DOMAIN public class SmallMap extends AbstractMap {      private Entry entry = null;      public void clear() { entry = null; }     public boolean isEmpty() { return entry==null; }         public int size() {         int r = 0;         for(Entry e = entry; e!=null; e = e.next) r++;         return r;     }      public boolean containsKey(Object key) {         for(Entry e = entry; e!=null; e = e.next){             if(e.key.equals(key)){                 return true;             }         }         return false;     }      public boolean containsValue(Object value) {         for(Entry e = entry; e!=null; e = e.next){             if(e.value==null){                 if(value==null) return true;             }else if(e.value.equals(value)){                 return true;             }         }         return false;     }      public Object get(Object key) {         for(Entry e = entry; e!=null; e = e.next){             if(e.key.equals(key)){                 return e.value;             }         }         return null;     }      public Object put(Object key, Object value) {         for(Entry e = entry; e!=null; e = e.next){             if(e.key.equals(key)){                 Object r = e.value;                 e.value = value;                 return r;             }         }         entry = new Entry(key, value, entry);         return null;     }      public Object remove(Object key) {         if(entry!=null){             if(entry.key.equals(key)){                 Object r = entry.value;                 entry = entry.next;                 return r;             }             for(Entry e = entry; e.next!=null; e = e.next){                 if(key.equals(e.next.key)){                     Object r = e.next.value;                     e.next = e.next.next;                     return r;                 }             }         }         return null;     }      public Set entrySet() { return new EntrySet(); }      class EntrySet extends AbstractSet{         public Iterator iterator() {             return new Iterator(){                  Entry last = null;                 Entry e = entry;                 public boolean hasNext() { return e!=null; }                  public Object next() {                      last = e;                     e = e.next;                     return last;                 }                  public void remove() {                      if(last == null) throw new IllegalStateException();                     SmallMap.this.remove(last.key);                 }             };         }          public int size() { return SmallMap.this.size();}     }      static private class Entry implements java.util.Map.Entry {         final Object key;         Object value;         Entry next;          Entry(Object key, Object value, Entry next){             if(key==null) throw new NullPointerException();             this.key = key;             this.value = value;             this.next = next;         }         public Object getKey() { return key; }         public Object getValue() { return value; }         public Object setValue(Object value) {              Object r = this.value;             this.value = value;             return r;         }         public int hashCode() {             return (key   == null ? 0 :   key.hashCode()) ^                (value == null ? 0 : value.hashCode());         }     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.