Java Doc for HashCommon.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » mem » 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 » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.mem 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.hp.hpl.jena.mem.HashCommon

All known Subclasses:   com.hp.hpl.jena.mem.HashedBunchMap,  com.hp.hpl.jena.mem.HashedTripleBunch,
HashCommon
abstract public class HashCommon (Code)
Shared stuff for our hashing implementations: does the base work for hashing and growth sizes.
author:
   kers

Inner Class :public static interface NotifyEmpty
Inner Class :final protected class MovedKeysIterator extends NiceIterator
Inner Class :final protected class BasicKeyIterator extends NiceIterator

Field Summary
public  intcapacity
     The capacity (length) of the key array.
protected  intchanges
     A count of the number of changes applied to this Hash object, used for detecting concurrent modifications.
protected  Object[]keys
     The keys of whatever table it is we're implementing.
final protected static  doubleloadFactor
     Jeremy suggests, from his experiments, that load factors more than 0.6 leave the table too dense, and little advantage is gained below 0.4. Although that was with a quadratic probe, I'm borrowing the same plausible range, and use 0.5 by default.
final static  int[]primes
    
protected  intsize
     The number of active elements in the table, maintained incrementally.
protected  intthreshold
     The threshold number of elements above which we resize the table; equal to the capacity times the load factor.

Constructor Summary
protected  HashCommon(int initialCapacity)
     Initialise this hashed thingy to have initialCapacity as its capacity and the corresponding threshold.

Method Summary
final protected  intfindSlot(Object key)
     Search for the slot in which key is found.
public  ObjectgetItemForTestingAt(int i)
     Answer the item at index i of keys.
protected  voidgrowCapacityAndThreshold()
     Work out the capacity and threshold sizes for a new improved bigger table (bigger by a factor of two, at present).
protected  intimproveHashCode(int hashCode)
     Answer the transformed hash code, intended to be an improvement on the objects own hashcode.
final protected  intinitialIndexFor(Object key)
     Answer the initial index for the object key in the table. With luck, this will be the final position for that object.
public  ExtendedIteratorkeyIterator()
    
public  ExtendedIteratorkeyIterator(NotifyEmpty container)
    
protected  voidmoveAssociatedValues(int here, int scan)
     When removeFrom [or remove] moves a key, it calls this method to move any associated values, passing in the index of the slot here to move to and the index of the slot scan to move from.
protected static  intnextSize(int atLeast)
    
public  voidremove(Object key)
     Remove the object key from this hash's keys if it is present (if it's absent, do nothing).
protected  voidremoveAssociatedValues(int here)
     When removeFrom [or remove] removes a key, it calls this method to remove any associated values, passing in the index of the key's slot.
protected  ObjectremoveFrom(int here)
     Remove the triple at element i of contents. This is an implementation of Knuth's Algorithm R from tAoCP vol3, p 527, with exchanging of the roles of i and j so that they can be usefully renamed to here and scan.

It relies on linear probing but doesn't require a distinguished REMOVED value.

 voidshowkeys()
    

Field Detail
capacity
public int capacity(Code)
The capacity (length) of the key array.



changes
protected int changes(Code)
A count of the number of changes applied to this Hash object, used for detecting concurrent modifications.



keys
protected Object[] keys(Code)
The keys of whatever table it is we're implementing. Since we share code for triple sets and for node->bunch maps, it has to be an Object array; we take the casting hit.



loadFactor
final protected static double loadFactor(Code)
Jeremy suggests, from his experiments, that load factors more than 0.6 leave the table too dense, and little advantage is gained below 0.4. Although that was with a quadratic probe, I'm borrowing the same plausible range, and use 0.5 by default.



primes
final static int[] primes(Code)



size
protected int size(Code)
The number of active elements in the table, maintained incrementally.



threshold
protected int threshold(Code)
The threshold number of elements above which we resize the table; equal to the capacity times the load factor.




Constructor Detail
HashCommon
protected HashCommon(int initialCapacity)(Code)
Initialise this hashed thingy to have initialCapacity as its capacity and the corresponding threshold. All the key elements start out null.




Method Detail
findSlot
final protected int findSlot(Object key)(Code)
Search for the slot in which key is found. If it is absent, return the index of the free slot in which it could be placed. If it is present, return the bitwise complement of the index of the slot it appears in. Hence negative values imply present, positive absent, and there's no confusion around 0.



getItemForTestingAt
public Object getItemForTestingAt(int i)(Code)
Answer the item at index i of keys. This method is for testing purposes only.



growCapacityAndThreshold
protected void growCapacityAndThreshold()(Code)
Work out the capacity and threshold sizes for a new improved bigger table (bigger by a factor of two, at present).



improveHashCode
protected int improveHashCode(int hashCode)(Code)
Answer the transformed hash code, intended to be an improvement on the objects own hashcode. The magic number 127 is performance voodoo to (try to) eliminate problems experienced by Wolfgang.



initialIndexFor
final protected int initialIndexFor(Object key)(Code)
Answer the initial index for the object key in the table. With luck, this will be the final position for that object. The initial index will always be non-negative and less than capacity.

Implementation note: do not use Math.abs to turn a hashcode into a positive value; there is a single specific integer on which it does not work. (Hence, here, the use of bitmasks.)




keyIterator
public ExtendedIterator keyIterator()(Code)



keyIterator
public ExtendedIterator keyIterator(NotifyEmpty container)(Code)



moveAssociatedValues
protected void moveAssociatedValues(int here, int scan)(Code)
When removeFrom [or remove] moves a key, it calls this method to move any associated values, passing in the index of the slot here to move to and the index of the slot scan to move from. Subclasses override if they have any associated values.



nextSize
protected static int nextSize(int atLeast)(Code)



remove
public void remove(Object key)(Code)
Remove the object key from this hash's keys if it is present (if it's absent, do nothing). If a key is removed, the removeAssociatedValues will be removed. If a key is moved, the moveAssociatedValues method will be called.



removeAssociatedValues
protected void removeAssociatedValues(int here)(Code)
When removeFrom [or remove] removes a key, it calls this method to remove any associated values, passing in the index of the key's slot. Subclasses override if they have any associated values.



removeFrom
protected Object removeFrom(int here)(Code)
Remove the triple at element i of contents. This is an implementation of Knuth's Algorithm R from tAoCP vol3, p 527, with exchanging of the roles of i and j so that they can be usefully renamed to here and scan.

It relies on linear probing but doesn't require a distinguished REMOVED value. Since we resize the table when it gets fullish, we don't worry [much] about the overhead of the linear probing.

Iterators running over the keys may miss elements that are moved from the top of the table to the bottom because of Iterator::remove. removeFrom returns such a moved key as its result, and null otherwise.




showkeys
void showkeys()(Code)



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.