Java Doc for THash.java in  » Development » trove » gnu » trove » 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 » Development » trove » gnu.trove 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   gnu.trove.THash

All known Subclasses:   gnu.trove.TPrimitiveHash,  gnu.trove.TObjectHash,
THash
abstract public class THash implements Cloneable(Code)
Base class for hashtables that use open addressing to resolve collisions. Created: Wed Nov 28 21:11:16 2001
author:
   Eric D. Friedman
author:
   Rob Eden (auto-compaction)
version:
   $Id: THash.java,v 1.10 2007/11/01 16:08:14 robeden Exp $


Field Summary
final protected static  intDEFAULT_INITIAL_CAPACITY
     the default initial capacity for the hash table.
final protected static  floatDEFAULT_LOAD_FACTOR
     the load above which rehashing occurs.
protected  int_autoCompactRemovesRemaining
     The number of removes that should be performed before an auto-compaction occurs.
protected  float_autoCompactionFactor
     The auto-compaction factor for the table.
protected transient  int_free
     the current number of free slots in the hash.
protected  float_loadFactor
     Determines how full the internal table can become before rehashing is required.
protected  int_maxSize
     The maximum number of elements allowed without allocating more space.
protected transient  int_size
     the current number of occupied slots in the hash.

Constructor Summary
public  THash()
     Creates a new THash instance with the default capacity and load factor.
public  THash(int initialCapacity)
     Creates a new THash instance with a prime capacity at or near the specified capacity and with the default load factor.
public  THash(int initialCapacity, float loadFactor)
     Creates a new THash instance with a prime capacity at or near the minimum needed to hold initialCapacity elements with load factor loadFactor without triggering a rehash.

Method Summary
protected  intcalculateGrownCapacity()
    
abstract protected  intcapacity()
    
public  voidclear()
     Empties the collection.
public  Objectclone()
    
public  voidcompact()
     Compresses the hashtable to the minimum prime size (as defined by PrimeFinder) that will hold all of the elements currently in the table.
public  voidensureCapacity(int desiredCapacity)
     Ensure that this hashtable has sufficient capacity to hold desiredCapacity additional elements without requiring a rehash.
public  floatgetAutoCompactionFactor()
    
public  booleanisEmpty()
     Tells whether this set is currently holding any elements.
final protected  voidpostInsertHook(boolean usedFreeSlot)
     After an insert, this hook is called to adjust the size/free values of the set and to perform rehashing if necessary.
protected  voidreenableAutoCompaction(boolean check_for_compaction)
     Re-enable auto-compaction after it was disabled via THash.tempDisableAutoCompaction() .
Parameters:
  check_for_compaction - True if compaction should be performed if neededbefore returning.
abstract protected  voidrehash(int newCapacity)
     Rehashes the set.
protected  voidremoveAt(int index)
     Delete the record at index.
public  voidsetAutoCompactionFactor(float factor)
     The auto-compaction factor controls whether and when a table performs a THash.compact automatically after a certain number of remove operations.
protected  intsetUp(int initialCapacity)
     initializes the hashtable to a prime capacity which is at least initialCapacity + 1.
public  intsize()
     Returns the number of distinct elements in this collection.
protected  voidtempDisableAutoCompaction()
     Temporarily disables auto-compaction.
final public  voidtrimToSize()
     This simply calls THash.compact compact .

Field Detail
DEFAULT_INITIAL_CAPACITY
final protected static int DEFAULT_INITIAL_CAPACITY(Code)
the default initial capacity for the hash table. This is one less than a prime value because one is added to it when searching for a prime capacity to account for the free slot required by open addressing. Thus, the real default capacity is 11.



DEFAULT_LOAD_FACTOR
final protected static float DEFAULT_LOAD_FACTOR(Code)
the load above which rehashing occurs.



_autoCompactRemovesRemaining
protected int _autoCompactRemovesRemaining(Code)
The number of removes that should be performed before an auto-compaction occurs.



_autoCompactionFactor
protected float _autoCompactionFactor(Code)
The auto-compaction factor for the table.
See Also:   THash.setAutoCompactionFactor



_free
protected transient int _free(Code)
the current number of free slots in the hash.



_loadFactor
protected float _loadFactor(Code)
Determines how full the internal table can become before rehashing is required. This must be a value in the range: 0.0 < loadFactor < 1.0. The default value is 0.5, which is about as large as you can get in open addressing without hurting performance. Cf. Knuth, Volume 3., Chapter 6.



_maxSize
protected int _maxSize(Code)
The maximum number of elements allowed without allocating more space.



_size
protected transient int _size(Code)
the current number of occupied slots in the hash.




Constructor Detail
THash
public THash()(Code)
Creates a new THash instance with the default capacity and load factor.



THash
public THash(int initialCapacity)(Code)
Creates a new THash instance with a prime capacity at or near the specified capacity and with the default load factor.
Parameters:
  initialCapacity - an int value



THash
public THash(int initialCapacity, float loadFactor)(Code)
Creates a new THash instance with a prime capacity at or near the minimum needed to hold initialCapacity elements with load factor loadFactor without triggering a rehash.
Parameters:
  initialCapacity - an int value
Parameters:
  loadFactor - a float value




Method Detail
calculateGrownCapacity
protected int calculateGrownCapacity()(Code)



capacity
abstract protected int capacity()(Code)
the current physical capacity of the hash table.



clear
public void clear()(Code)
Empties the collection.



clone
public Object clone()(Code)



compact
public void compact()(Code)
Compresses the hashtable to the minimum prime size (as defined by PrimeFinder) that will hold all of the elements currently in the table. If you have done a lot of remove operations and plan to do a lot of queries or insertions or iteration, it is a good idea to invoke this method. Doing so will accomplish two things:
  1. You'll free memory allocated to the table but no longer needed because of the remove()s.
  2. You'll get better query/insert/iterator performance because there won't be any REMOVED slots to skip over when probing for indices in the table.



ensureCapacity
public void ensureCapacity(int desiredCapacity)(Code)
Ensure that this hashtable has sufficient capacity to hold desiredCapacity additional elements without requiring a rehash. This is a tuning method you can call before doing a large insert.
Parameters:
  desiredCapacity - an int value



getAutoCompactionFactor
public float getAutoCompactionFactor()(Code)

See Also:   THash.setAutoCompactionFactor



isEmpty
public boolean isEmpty()(Code)
Tells whether this set is currently holding any elements. a boolean value



postInsertHook
final protected void postInsertHook(boolean usedFreeSlot)(Code)
After an insert, this hook is called to adjust the size/free values of the set and to perform rehashing if necessary.



reenableAutoCompaction
protected void reenableAutoCompaction(boolean check_for_compaction)(Code)
Re-enable auto-compaction after it was disabled via THash.tempDisableAutoCompaction() .
Parameters:
  check_for_compaction - True if compaction should be performed if neededbefore returning. If false, no compaction will beperformed.



rehash
abstract protected void rehash(int newCapacity)(Code)
Rehashes the set.
Parameters:
  newCapacity - an int value



removeAt
protected void removeAt(int index)(Code)
Delete the record at index. Reduces the size of the collection by one.
Parameters:
  index - an int value



setAutoCompactionFactor
public void setAutoCompactionFactor(float factor)(Code)
The auto-compaction factor controls whether and when a table performs a THash.compact automatically after a certain number of remove operations. If the value is non-zero, the number of removes that need to occur for auto-compaction is the size of table at the time of the previous compaction (or the initial capacity) multiplied by this factor.

Setting this value to zero will disable auto-compaction.




setUp
protected int setUp(int initialCapacity)(Code)
initializes the hashtable to a prime capacity which is at least initialCapacity + 1.
Parameters:
  initialCapacity - an int value the actual capacity chosen



size
public int size()(Code)
Returns the number of distinct elements in this collection. an int value



tempDisableAutoCompaction
protected void tempDisableAutoCompaction()(Code)
Temporarily disables auto-compaction. MUST be followed by calling THash.reenableAutoCompaction .



trimToSize
final public void trimToSize()(Code)
This simply calls THash.compact compact . It is included for symmetry with other collection classes. Note that the name of this method is somewhat misleading (which is why we prefer compact) as the load factor may require capacity above and beyond the size of this collection.
See Also:   THash.compact



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.