Exemple #1
0
        //-----------------------------------------------------------------------

        /**
         * Gets the value mapped to the specified multi-key.
         *
         * @param key1  the first key
         * @param key2  the second key
         * @param key3  the third key
         * @param key4  the fourth key
         * @param key5  the fifth key
         * @return the mapped value, null if no match
         */
        public Object get(Object key1, Object key2, Object key3, Object key4, Object key5)
        {
            int hashCode = hash(key1, key2, key3, key4, key5);

            AbstractHashedMap.HashEntry entry = map.data[map.hashIndex(hashCode, map.data.Length)];
            while (entry != null)
            {
                if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5))
                {
                    return(entry.getValue());
                }
                entry = entry.nextJ;
            }
            return(null);
        }
Exemple #2
0
        /**
         * Removes the specified multi-key from this map.
         *
         * @param key1  the first key
         * @param key2  the second key
         * @param key3  the third key
         * @param key4  the fourth key
         * @param key5  the fifth key
         * @return the value mapped to the removed key, null if key not in map
         */
        public Object remove(Object key1, Object key2, Object key3, Object key4, Object key5)
        {
            int hashCode = hash(key1, key2, key3, key4, key5);
            int index    = map.hashIndex(hashCode, map.data.Length);

            AbstractHashedMap.HashEntry entry    = map.data[index];
            AbstractHashedMap.HashEntry previous = null;
            while (entry != null)
            {
                if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5))
                {
                    Object oldValue = entry.getValue();
                    map.removeMapping(entry, index, previous);
                    return(oldValue);
                }
                previous = entry;
                entry    = entry.nextJ;
            }
            return(null);
        }
Exemple #3
0
        /**
         * Stores the value against the specified multi-key.
         *
         * @param key1  the first key
         * @param key2  the second key
         * @param key3  the third key
         * @param key4  the fourth key
         * @param key5  the fifth key
         * @param value  the value to store
         * @return the value previously mapped to this combined key, null if none
         */
        public Object put(Object key1, Object key2, Object key3, Object key4, Object key5, Object value)
        {
            int hashCode = hash(key1, key2, key3, key4, key5);
            int index    = map.hashIndex(hashCode, map.data.Length);

            AbstractHashedMap.HashEntry entry = map.data[index];
            while (entry != null)
            {
                if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5))
                {
                    Object oldValue = entry.getValue();
                    map.updateEntry(entry, value);
                    return(oldValue);
                }
                entry = entry.nextJ;
            }

            map.addMapping(index, hashCode, new MultiKey(key1, key2, key3, key4, key5), value);
            return(null);
        }