IT. Expert System.

Android Reference

LinkedHashMap


java.util

Class LinkedHashMap<K,V>

  • All Implemented Interfaces:
    Serializable, Cloneable, Map<K,V>


    public class LinkedHashMap<K,V>
    extends HashMap<K,V>
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations are supported.

    All elements are permitted as keys or values, including null.

    Entries are kept in a doubly-linked list. The iteration order is, by default, the order in which keys were inserted. Reinserting an already-present key doesn't change the order. If the three argument constructor is used, and accessOrder is specified as true, the iteration will be in the order that entries were accessed. The access order is affected by put, get, and putAll operations, but not by operations on the collection views.

    Note: the implementation of LinkedHashMap is not synchronized. If one thread of several threads accessing an instance modifies the map structurally, access to the map needs to be synchronized. For insertion-ordered instances a structural modification is an operation that removes or adds an entry. Access-ordered instances also are structurally modified by put, get, and putAll since these methods change the order of the entries. Changes in the value of an entry are not structural changes.

    The Iterator created by calling the iterator method may throw a ConcurrentModificationException if the map is structurally changed while an iterator is used to iterate over the elements. Only the remove method that is provided by the iterator allows for removal of elements during iteration. It is not possible to guarantee that this mechanism works in all cases of unsynchronized concurrent modification. It should only be used for debugging purposes.

    See Also:
    Serialized Form
    • Constructor Detail

      • LinkedHashMap

        public LinkedHashMap()
        Constructs a new empty LinkedHashMap instance.
      • LinkedHashMap

        public LinkedHashMap(int initialCapacity)
        Constructs a new LinkedHashMap instance with the specified capacity.
        Parameters:
        initialCapacity - the initial capacity of this map.
        Throws:
        IllegalArgumentException - when the capacity is less than zero.
      • LinkedHashMap

        public LinkedHashMap(int initialCapacity,
                     float loadFactor)
        Constructs a new LinkedHashMap instance with the specified capacity and load factor.
        Parameters:
        initialCapacity - the initial capacity of this map.
        loadFactor - the initial load factor.
        Throws:
        IllegalArgumentException - when the capacity is less than zero or the load factor is less or equal to zero.
      • LinkedHashMap

        public LinkedHashMap(int initialCapacity,
                     float loadFactor,
                     boolean accessOrder)
        Constructs a new LinkedHashMap instance with the specified capacity, load factor and a flag specifying the ordering behavior.
        Parameters:
        initialCapacity - the initial capacity of this hash map.
        loadFactor - the initial load factor.
        accessOrder - true if the ordering should be done based on the last access (from least-recently accessed to most-recently accessed), and false if the ordering should be the order in which the entries were inserted.
        Throws:
        IllegalArgumentException - when the capacity is less than zero or the load factor is less or equal to zero.
      • LinkedHashMap

        public LinkedHashMap(Map<? extends K,? extends V> map)
        Constructs a new LinkedHashMap instance containing the mappings from the specified map. The order of the elements is preserved.
        Parameters:
        map - the mappings to add.
    • Method Detail

      • eldest

        public Map.Entry<K,V> eldest()
        Returns the eldest entry in the map, or null if the map is empty.
      • get

        public V get(Object key)
        Returns the value of the mapping with the specified key.
        Specified by:
        get in interface Map<K,V>
        Overrides:
        get in class HashMap<K,V>
        Parameters:
        key - the key.
        Returns:
        the value of the mapping with the specified key, or null if no mapping for the specified key is found.
      • containsValue

        public boolean containsValue(Object value)
        This override is done for LinkedHashMap performance: iteration is cheaper via LinkedHashMap nxt links.
        Specified by:
        containsValue in interface Map<K,V>
        Overrides:
        containsValue in class HashMap<K,V>
        Parameters:
        value - the value to search for.
        Returns:
        true if this map contains the specified value, false otherwise.
      • removeEldestEntry

        protected boolean removeEldestEntry(Map.Entry<K,V> eldest)


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 2421 / . Delta: 0.02379 с