Side of Software
Dated Collections Library 2.0

sos.dated.util
Class LinkedHashMapByDate<K,V,D>

java.lang.Object
  extended by sos.dated.util.AbstractDatedObject<D>
      extended by sos.dated.util.AbstractDatedMap<K,V,D>
          extended by sos.dated.util.AbstractMapByDate<K,V,D>
              extended by sos.dated.util.LinkedHashMapByDate<K,V,D>
Type Parameters:
K - the type of keys maintained by this dated map
V - the type of values maintained by this dated map
D - the type of dates used by this dated map
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, DatedMap<K,V,D>, DatedObject<D>

public class LinkedHashMapByDate<K,V,D>
extends AbstractMapByDate<K,V,D>
implements DatedMap<K,V,D>, java.io.Serializable, java.lang.Cloneable

An implementation of DatedMap that maintains a java.util.LinkedHashMap at each date where a change occurs, yielding fast date iterations, fast retrievals, and predictable entry iterations.

This implementation is serializable and cloneable; however, it is not synchronized. To use it safely in a multi-threaded situation, wrap an instance of the dated map with a call to DatedCollections.synchronizedDatedMap.

Since:
2.0
See Also:
LinkedHashSetByDate, DatedMap, DatedCollections.synchronizedDatedMap(DatedMap)

Nested Class Summary
 
Nested classes/interfaces inherited from interface sos.dated.util.DatedMap
DatedMap.Entry<K,V,D>
 
Constructor Summary
LinkedHashMapByDate()
          Creates an insertion-ordered LinkedHashMapByDate with a default initial capacity (16) and a default load factor (0.75).
LinkedHashMapByDate(DatedMap<? extends K,? extends V,D> datedMap)
          Constructs an insertion-order LinkedHashMapByDate initialized with the mappings of datedMap.
LinkedHashMapByDate(int initialCapacity)
          Constructs an insertion-ordered LinkedHashMapByDate with the specified initial capacity and a default load factor (0.75).
LinkedHashMapByDate(int initialCapacity, float loadFactor)
          Constructs an insertion-ordered LinkedHashMapByDate with the specified initial capacity and load factor.
LinkedHashMapByDate(int initialCapacity, float loadFactor, boolean accessOrder)
          Constructs an instance of LinkedHashMapByDate with the specified initial capacity, load factor, and ordering mode.
 
Method Summary
 java.lang.Object clone()
          Creates and returns a shallow copy of this object.
protected  java.util.Map<K,V> createMap(D from, D to)
          Returns a freshly created, empty LinkedHashMap.
protected  boolean removeEldestEntry(DatedMap.Entry<K,V,D> entry, D from, D to)
          Returns true if this map should remove the specified eldest entry for a given date range.
 
Methods inherited from class sos.dated.util.AbstractMapByDate
checkForComodification, containsKey, containsValue, copyMap, dateIterator, entrySet, get, modCount, put, putAll, remove, upModCount
 
Methods inherited from class sos.dated.util.AbstractDatedMap
clear, containsKeyThroughout, containsValueThroughout, equals, excludesKeyThroughout, excludesValueThroughout, get, hashCode, hasSizeThroughout, isEmpty, isEmptyThroughout, keySet, size, toString, values
 
Methods inherited from class sos.dated.util.AbstractDatedObject
dateIterator, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface sos.dated.util.DatedMap
clear, containsKey, containsKeyThroughout, containsValue, containsValueThroughout, entrySet, equals, excludesKeyThroughout, excludesValueThroughout, get, get, hashCode, hasSizeThroughout, isEmpty, isEmptyThroughout, keySet, put, putAll, remove, size, values
 
Methods inherited from interface sos.dated.util.DatedObject
dateIterator, dateIterator, equals, hashCode, toString
 

Constructor Detail

LinkedHashMapByDate

public LinkedHashMapByDate()
Creates an insertion-ordered LinkedHashMapByDate with a default initial capacity (16) and a default load factor (0.75).


LinkedHashMapByDate

public LinkedHashMapByDate(int initialCapacity)
Constructs an insertion-ordered LinkedHashMapByDate with the specified initial capacity and a default load factor (0.75).

Parameters:
initialCapacity - the initial capacity at all dates
Throws:
java.lang.IllegalArgumentException - if initialCapacity < 0

LinkedHashMapByDate

public LinkedHashMapByDate(int initialCapacity,
                           float loadFactor)
Constructs an insertion-ordered LinkedHashMapByDate with the specified initial capacity and load factor.

Parameters:
initialCapacity - the initial capacity at all dates
loadFactor - the load factor at all dates
Throws:
java.lang.IllegalArgumentException - if initialCapacity < 0 or if loadFactor <= 0.0

LinkedHashMapByDate

public LinkedHashMapByDate(int initialCapacity,
                           float loadFactor,
                           boolean accessOrder)
Constructs an instance of LinkedHashMapByDate with the specified initial capacity, load factor, and ordering mode.

Parameters:
initialCapacity - the initial capacity at all dates
loadFactor - the load factor at all dates
accessOrder - true for access order, false for insertion order
Throws:
java.lang.IllegalArgumentException - if initialCapacity < 0 or if loadFactor <= 0.0

LinkedHashMapByDate

public LinkedHashMapByDate(DatedMap<? extends K,? extends V,D> datedMap)
Constructs an insertion-order LinkedHashMapByDate initialized with the mappings of datedMap.

Parameters:
datedMap - dated map with which to initialize this LinkedHashMapByDate
Throws:
java.lang.NullPointerException - if datedMap is null.
Method Detail

clone

public java.lang.Object clone()
Creates and returns a shallow copy of this object.

Overrides:
clone in class AbstractMapByDate<K,V,D>
Returns:
a clone of this instance

createMap

protected java.util.Map<K,V> createMap(D from,
                                       D to)
Returns a freshly created, empty LinkedHashMap.

Specified by:
createMap in class AbstractMapByDate<K,V,D>
Parameters:
from - start date (inclusive) for which to create the map
to - end date (exclusive) for which to create the map
Returns:
a freshly created, empty LinkedHashMap.

removeEldestEntry

protected boolean removeEldestEntry(DatedMap.Entry<K,V,D> entry,
                                    D from,
                                    D to)
Returns true if this map should remove the specified eldest entry for a given date range.

Parameters:
entry - eldest entry in question
from - start of date range (inclusive) for which the entry is the eldest
to - end of date range (exclusive) for which the entry is the eldest
Returns:
true if entry should be removed
Throws:
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if from or to is null

Side of Software
Dated Collections Library 2.0

Copyright 2003-09 Side of Software (SOS). All rights reserved.