Java Doc for SequencedHashMap.java in  » Library » Apache-common-Collections » org » apache » commons » collections » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache common Collections » org.apache.commons.collections 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.collections.SequencedHashMap

All known Subclasses:   org.apache.commons.collections.LRUMap,
SequencedHashMap
public class SequencedHashMap implements Map,Cloneable,Externalizable(Code)
A map of objects whose mapping entries are sequenced based on the order in which they were added. This data structure has fast O(1) search time, deletion time, and insertion time.

Although this map is sequenced, it cannot implement java.util.List because of incompatible interface definitions. The remove methods in List and Map have different return values (see: java.util.List.remove(Object) and java.util.Map.remove(Object) ).

This class is not thread safe. When a thread safe implementation is required, use java.util.Collections.synchronizedMap(Map) as it is documented, or use explicit synchronization controls.
See Also:   org.apache.commons.collections.map.LinkedMap
See Also:   org.apache.commons.collections.map.ListOrderedMap
since:
   Commons Collections 2.0
version:
   $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
author:
   Michael A. Smith
author:
   Daniel Rall
author:
   Henning P. Schmiedehausen
author:
   Stephen Colebourne




Constructor Summary
public  SequencedHashMap()
     Construct a new sequenced hash map with default initial size and load factor.
public  SequencedHashMap(int initialSize)
     Construct a new sequenced hash map with the specified initial size and default load factor.
public  SequencedHashMap(int initialSize, float loadFactor)
     Construct a new sequenced hash map with the specified initial size and load factor.
public  SequencedHashMap(Map m)
     Construct a new sequenced hash map and add all the elements in the specified map.

Method Summary
public  voidclear()
     Implements Map.clear .
public  Objectclone()
     Creates a shallow copy of this object, preserving the internal structure by copying only references.
public  booleancontainsKey(Object key)
     Implements Map.containsKey(Object) .
public  booleancontainsValue(Object value)
     Implements Map.containsValue(Object) .
public  SetentrySet()
     Implements Map.entrySet .
public  booleanequals(Object obj)
     Implements Map.equals(Object) .
public  Objectget(Object o)
     Implements Map.get(Object) .
public  Objectget(int index)
     Gets the key at the specified index.
public  Map.EntrygetFirst()
     Return the entry for the "oldest" mapping.
public  ObjectgetFirstKey()
     Return the key for the "oldest" mapping.
public  ObjectgetFirstValue()
     Return the value for the "oldest" mapping.
public  Map.EntrygetLast()
     Return the entry for the "newest" mapping.
public  ObjectgetLastKey()
     Return the key for the "newest" mapping.
public  ObjectgetLastValue()
     Return the value for the "newest" mapping.
public  ObjectgetValue(int index)
     Gets the value at the specified index.
public  inthashCode()
     Implements Map.hashCode .
public  intindexOf(Object key)
     Gets the index of the specified key.
public  booleanisEmpty()
     Implements Map.isEmpty .
public  Iteratoriterator()
     Gets an iterator over the keys.
public  SetkeySet()
     Implements Map.keySet .
public  intlastIndexOf(Object key)
     Gets the last index of the specified key.
public  Objectput(Object key, Object value)
     Implements Map.put(ObjectObject) .
public  voidputAll(Map t)
     Adds all the mappings in the specified map to this map, replacing any mappings that already exist (as per Map.putAll(Map) ).
public  voidreadExternal(ObjectInput in)
     Deserializes this map from the given stream.
public  Objectremove(Object key)
     Implements Map.remove(Object) .
public  Objectremove(int index)
     Removes the element at the specified index.
Parameters:
  index - The index of the object to remove.
public  Listsequence()
     Returns a List view of the keys rather than a set view.
public  intsize()
     Implements Map.size .
public  StringtoString()
     Provides a string representation of the entries within the map.
public  Collectionvalues()
     Implements Map.values .
public  voidwriteExternal(ObjectOutput out)
     Serializes this map to the given stream.


Constructor Detail
SequencedHashMap
public SequencedHashMap()(Code)
Construct a new sequenced hash map with default initial size and load factor.



SequencedHashMap
public SequencedHashMap(int initialSize)(Code)
Construct a new sequenced hash map with the specified initial size and default load factor.
Parameters:
  initialSize - the initial size for the hash table
See Also:   HashMap.HashMap(int)



SequencedHashMap
public SequencedHashMap(int initialSize, float loadFactor)(Code)
Construct a new sequenced hash map with the specified initial size and load factor.
Parameters:
  initialSize - the initial size for the hash table
Parameters:
  loadFactor - the load factor for the hash table.
See Also:   HashMap.HashMap(intfloat)



SequencedHashMap
public SequencedHashMap(Map m)(Code)
Construct a new sequenced hash map and add all the elements in the specified map. The order in which the mappings in the specified map are added is defined by SequencedHashMap.putAll(Map) .




Method Detail
clear
public void clear()(Code)
Implements Map.clear .



clone
public Object clone() throws CloneNotSupportedException(Code)
Creates a shallow copy of this object, preserving the internal structure by copying only references. The keys and values themselves are not clone()'d. The cloned object maintains the same sequence. A clone of this instance.
throws:
  CloneNotSupportedException - if clone is not supported by asubclass.



containsKey
public boolean containsKey(Object key)(Code)
Implements Map.containsKey(Object) .



containsValue
public boolean containsValue(Object value)(Code)
Implements Map.containsValue(Object) .



entrySet
public Set entrySet()(Code)
Implements Map.entrySet .



equals
public boolean equals(Object obj)(Code)
Implements Map.equals(Object) .



get
public Object get(Object o)(Code)
Implements Map.get(Object) .



get
public Object get(int index)(Code)
Gets the key at the specified index.
Parameters:
  index - the index to retrieve the key at the specified index, or null
throws:
  ArrayIndexOutOfBoundsException - if the index is< 0 or > the size of the map.



getFirst
public Map.Entry getFirst()(Code)
Return the entry for the "oldest" mapping. That is, return the Map.Entry for the key-value pair that was first put into the map when compared to all the other pairings in the map. This behavior is equivalent to using entrySet().iterator().next(), but this method provides an optimized implementation. The first entry in the sequence, or null if themap is empty.



getFirstKey
public Object getFirstKey()(Code)
Return the key for the "oldest" mapping. That is, return the key for the mapping that was first put into the map when compared to all the other objects in the map. This behavior is equivalent to using getFirst().getKey(), but this method provides a slightly optimized implementation. The first key in the sequence, or null if themap is empty.



getFirstValue
public Object getFirstValue()(Code)
Return the value for the "oldest" mapping. That is, return the value for the mapping that was first put into the map when compared to all the other objects in the map. This behavior is equivalent to using getFirst().getValue(), but this method provides a slightly optimized implementation. The first value in the sequence, or null if themap is empty.



getLast
public Map.Entry getLast()(Code)
Return the entry for the "newest" mapping. That is, return the Map.Entry for the key-value pair that was first put into the map when compared to all the other pairings in the map. The behavior is equivalent to:
 Object obj = null;
 Iterator iter = entrySet().iterator();
 while(iter.hasNext()) {
 obj = iter.next();
 }
 return (Map.Entry)obj;
 
However, the implementation of this method ensures an O(1) lookup of the last key rather than O(n). The last entry in the sequence, or null if the mapis empty.



getLastKey
public Object getLastKey()(Code)
Return the key for the "newest" mapping. That is, return the key for the mapping that was last put into the map when compared to all the other objects in the map. This behavior is equivalent to using getLast().getKey(), but this method provides a slightly optimized implementation. The last key in the sequence, or null if the map isempty.



getLastValue
public Object getLastValue()(Code)
Return the value for the "newest" mapping. That is, return the value for the mapping that was last put into the map when compared to all the other objects in the map. This behavior is equivalent to using getLast().getValue(), but this method provides a slightly optimized implementation. The last value in the sequence, or null if the mapis empty.



getValue
public Object getValue(int index)(Code)
Gets the value at the specified index.
Parameters:
  index - the index to retrieve the value at the specified index, or null
throws:
  ArrayIndexOutOfBoundsException - if the index is< 0 or > the size of the map.



hashCode
public int hashCode()(Code)
Implements Map.hashCode .



indexOf
public int indexOf(Object key)(Code)
Gets the index of the specified key.
Parameters:
  key - the key to find the index of the index, or -1 if not found



isEmpty
public boolean isEmpty()(Code)
Implements Map.isEmpty .



iterator
public Iterator iterator()(Code)
Gets an iterator over the keys. an iterator over the keys



keySet
public Set keySet()(Code)
Implements Map.keySet .



lastIndexOf
public int lastIndexOf(Object key)(Code)
Gets the last index of the specified key.
Parameters:
  key - the key to find the index of the index, or -1 if not found



put
public Object put(Object key, Object value)(Code)
Implements Map.put(ObjectObject) .



putAll
public void putAll(Map t)(Code)
Adds all the mappings in the specified map to this map, replacing any mappings that already exist (as per Map.putAll(Map) ). The order in which the entries are added is determined by the iterator returned from Map.entrySet for the specified map.
Parameters:
  t - the mappings that should be added to this map.
throws:
  NullPointerException - if t is null



readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException(Code)
Deserializes this map from the given stream.
Parameters:
  in - the stream to deserialize from
throws:
  IOException - if the stream raises it
throws:
  ClassNotFoundException - if the stream raises it



remove
public Object remove(Object key)(Code)
Implements Map.remove(Object) .



remove
public Object remove(int index)(Code)
Removes the element at the specified index.
Parameters:
  index - The index of the object to remove. The previous value corresponding the key, ornull if none existed.
throws:
  ArrayIndexOutOfBoundsException - if the index is< 0 or > the size of the map.



sequence
public List sequence()(Code)
Returns a List view of the keys rather than a set view. The returned list is unmodifiable. This is required because changes to the values of the list (using java.util.ListIterator.set(Object) ) will effectively remove the value from the list and reinsert that value at the end of the list, which is an unexpected side effect of changing the value of a list. This occurs because changing the key, changes when the mapping is added to the map and thus where it appears in the list.

An alternative to this method is to use SequencedHashMap.keySet()
See Also:   SequencedHashMap.keySet() The ordered list of keys.




size
public int size()(Code)
Implements Map.size .



toString
public String toString()(Code)
Provides a string representation of the entries within the map. The format of the returned string may change with different releases, so this method is suitable for debugging purposes only. If a specific format is required, use SequencedHashMap.entrySet() . Set.iterator iterator() and iterate over the entries in the map formatting them as appropriate.



values
public Collection values()(Code)
Implements Map.values .



writeExternal
public void writeExternal(ObjectOutput out) throws IOException(Code)
Serializes this map to the given stream.
Parameters:
  out - the stream to serialize to
throws:
  IOException - if the stream raises it



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.