Merge pull request #5 from square/py/perflib
Swiching to Perflib
diff --git a/.gitignore b/.gitignore
index 24e9aff..ee06bec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@
target
pom.xml.*
release.properties
+dependency-reduced-pom.xml
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..d08c432
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,6 @@
+[submodule "android_platform_tool_base"]
+ path = android_platform_tool_base
+ url = https://android.googlesource.com/platform/tools/base
+[submodule "android_platform_prebuilts_tools"]
+ path = android_platform_prebuilts_tools
+ url = https://android.googlesource.com/platform/prebuilts/tools/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e08e453..ed1e4c3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Change Log
+## Version 2.0-SNAPSHOT
+
+Switched hprof parsing from AndrodMat to [perflib](https://android.googlesource.com/platform/tools/base/+/studio-master-dev/perflib)
+
+As a result, althought similar in spirit, all the APIs have changed.
+
## Version 1.3 *(2015-05-12)*
No caching of the result of parsing the heap dump. This could lead to stack overflow errors, and we don't need it anyway since our use case is to always open a heap dump, parse it, compute a result and throw away the index files.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..338b931
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,16 @@
+# Contributing
+
+If you would like to contribute code to LeakCanary you can do so through GitHub by
+forking the repository and sending a pull request.
+
+When submitting code, please make every effort to follow existing conventions
+and style in order to keep the code as readable as possible. Please also make
+sure your code compiles by running `./gradlew clean build`. Checkstyle failures
+during compilation indicate errors in your style and can be viewed in files
+located at `*/build/report/checkstyle` directories.
+
+Before your code can be accepted into the project you must also sign the
+[Individual Contributor License Agreement (CLA)][1].
+
+
+ [1]: https://spreadsheets.google.com/spreadsheet/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
index 3d967ae..7a4a3ea 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,70 +1,202 @@
-Eclipse Public License - v 1.0
-THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
-1. DEFINITIONS
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-"Contribution" means:
+ 1. Definitions.
-a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
-b) in the case of each subsequent Contributor:
-i) changes to the Program, and
-ii) additions to the Program;
-where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
-"Contributor" means any person or entity that distributes the Program.
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
-"Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
-"Program" means the Contributions distributed in accordance with this Agreement.
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
-"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
-2. GRANT OF RIGHTS
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
-a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
-b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
-c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
-d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
-3. REQUIREMENTS
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
-A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
-a) it complies with the terms and conditions of this Agreement; and
-b) its license agreement:
-i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
-ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
-iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
-iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
-When the Program is made available in source code form:
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
-a) it must be made available under this Agreement; and
-b) a copy of this Agreement must be included with each copy of the Program.
-Contributors may not remove or alter any copyright notices contained within the Program.
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
-Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
-4. COMMERCIAL DISTRIBUTION
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
-Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
-For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
-5. NO WARRANTY
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
-6. DISCLAIMER OF LIABILITY
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
-7. GENERAL
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
-If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
-If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
-All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
-Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
-This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
\ No newline at end of file
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
diff --git a/README.md b/README.md
index 32017e9..71b0ad3 100644
--- a/README.md
+++ b/README.md
@@ -7,12 +7,7 @@
HAHA is a Java library to automate the analysis of Android heap dumps.
-This project is the result of a series of forks, and we have done very little work apart from making it available as a Maven dependency. Here's the fork history:
-
-* [Eclipse Memory Analyzer](https://eclipse.org/mat) (MAT) is a Java heap analyzer. It's a standalone GUI built with Eclipse RCP that embeds an engine to parse and analyze heap dumps.
-* [vshor/mat](https://bitbucket.org/vshor/mat) is a fork of *Eclipse Memory Analyzer*. It removed a lot of code and changed some of it to make a headless version (no GUI), as well as ignore weak references when finding paths to GC Roots.
-* [AndroMAT](https://bitbucket.org/joebowbeer/andromat/overview) is a fork of *vshor/mat* and changed the heap dump parsing to support Android specific heap dump format.
-* *HAHA* is a fork of *AndroMAT*. We recreated the lost Git history, kept the bare minimum needed code and packaged it to be releasable on Maven Central.
+This project is essentially a repackaging of the work of others to make it available as a small footprint Maven dependency.
## Usage
@@ -23,26 +18,45 @@
Debug.dumpHprofData(heapDumpFile.getAbsolutePath());
```
-After dumping the heap, use HAHA to parse and analyze it. The closest thing to documentation would probably be the [Eclipse Memory Analyzer API](http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Fdoc%2Findex.html&overview-summary.html), or simply reading the sources.
+After dumping the heap, use HAHA to parse and analyze it.
```
-SnapshotFactory factory = new SnapshotFactory();
-Map<String, String> args = Collections.emptyMap();
-VoidProgressListener listener = new VoidProgressListener();
-ISnapshot snapshot = factory.openSnapshot(heapDumpFile, args, listener);
+HprofBuffer buffer = new MemoryMappedFileBuffer(heapDumpFile);
+HprofParser parser = new HprofParser(buffer);
+Snapshot snapshot = parser.parse();
// The rest is up to you.
-Collection<IClass> refClasses = snapshot.getClassesByName("com.example.SomeClass", false);
+ClassObj someClass = snapshot.findClass("com.example.SomeClass");
```
## Gradle config
```
+repositories {
+ mavenCentral()
+ maven {
+ url 'https://oss.sonatype.org/content/repositories/snapshots/'
+ }
+}
dependencies {
- compile 'com.squareup.haha:haha:1.3'
+ compile 'com.squareup.haha:haha:2.0-SNAPSHOT'
}
```
-## Contributing
+## Versions
-We aren't accepting external contributions at this time.
\ No newline at end of file
+### HAHA 2.0
+
+* This library contains parts of [perflib](https://android.googlesource.com/platform/tools/base/+/studio-master-dev/perflib) and is available under the same license, Apache v2.
+* It contains a repackaged version of Guava and Trove4j "1.1 with patches from JetBrains"
+* Trove4j is available under the LGPL 2.1 license.
+* The result is merged in an uber-jar proguarded to remove unused code and reduce the footprint.
+
+### HAHA 1.1, 1.2 and 1.3
+
+* The first versions of HAHA were the result of a series of forks:
+* [Eclipse Memory Analyzer](https://eclipse.org/mat) (MAT) is a Java heap analyzer. It's a standalone GUI built with Eclipse RCP that embeds an engine to parse and analyze heap dumps.
+* [vshor/mat](https://bitbucket.org/vshor/mat) is a fork of *Eclipse Memory Analyzer*. It removed a lot of code and changed some of it to make a headless version (no GUI), as well as ignore weak references when finding paths to GC Roots.
+* [AndroMAT](https://bitbucket.org/joebowbeer/andromat/overview) is a fork of *vshor/mat* and changed the heap dump parsing to support Android specific heap dump format.
+* *HAHA* was originally a fork of *AndroMAT*. We recreated the lost Git history, kept the bare minimum needed code and packaged it to be releasable on Maven Central.
+* MAT is available under the Eclipse Public License v1.0 so HAHA was initially released under that same license.
\ No newline at end of file
diff --git a/android_platform_prebuilts_tools b/android_platform_prebuilts_tools
new file mode 160000
index 0000000..3fde540
--- /dev/null
+++ b/android_platform_prebuilts_tools
@@ -0,0 +1 @@
+Subproject commit 3fde540f482afc68b847f8e85672acc145606ffe
diff --git a/android_platform_tool_base b/android_platform_tool_base
new file mode 160000
index 0000000..a6d81db
--- /dev/null
+++ b/android_platform_tool_base
@@ -0,0 +1 @@
+Subproject commit a6d81dbdab6eee8aaff15a6a467a7457b43fce5c
diff --git a/pom.xml b/pom.xml
index 2ee8278..e1591a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -11,10 +13,10 @@
<groupId>com.squareup.haha</groupId>
<artifactId>haha</artifactId>
- <version>1.4-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<name>Headless Android Heap Analyzer</name>
- <description>Port of Eclipse Memory Analyzer to parse and analyze Android heapdumps</description>
+ <description>Java library to automate the analysis of Android heap dumps.</description>
<url>https://github.com/square/haha</url>
<inceptionYear>2015</inceptionYear>
@@ -30,15 +32,15 @@
<url>http://squareup.com</url>
</organization>
- <issueManagement>
+ <issueManagement>
<system>GitHub Issues</system>
<url>http://github.com/square/haha/issues</url>
</issueManagement>
<licenses>
<license>
- <name>Eclipse Public License - v 1.0</name>
- <url>http://www.eclipse.org/org/documents/epl-v10.php</url>
+ <name>Apache 2</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
@@ -64,6 +66,14 @@
</snapshotRepository>
</distributionManagement>
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>17.0</version>
+ </dependency>
+ </dependencies>
+
<build>
<plugins>
<plugin>
@@ -79,12 +89,12 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
- <configuration>
- <autoVersionSubmodules>true</autoVersionSubmodules>
- <useReleaseProfile>false</useReleaseProfile>
- <releaseProfiles>release</releaseProfiles>
- <goals>deploy</goals>
- </configuration>
+ <configuration>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ <useReleaseProfile>false</useReleaseProfile>
+ <releaseProfiles>release</releaseProfiles>
+ <goals>deploy</goals>
+ </configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
@@ -97,6 +107,65 @@
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.4.1</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <minimizeJar>true</minimizeJar>
+ <relocations>
+ <relocation>
+ <pattern>com.google.common</pattern>
+ <shadedPattern>com.squareup.haha.guava</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>gnu.trove</pattern>
+ <shadedPattern>com.squareup.haha.trove</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.android.annotations</pattern>
+ <shadedPattern>com.squareup.haha.annotations</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.android.tools.perflib.heap</pattern>
+ <shadedPattern>com.squareup.haha.perflib</shadedPattern>
+ </relocation>
+ </relocations>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.github.wvengen</groupId>
+ <artifactId>proguard-maven-plugin</artifactId>
+ <version>2.0.10</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>proguard</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <obfuscate>false</obfuscate>
+ <options>
+ <option>-allowaccessmodification</option>
+ <option>-keep class com.squareup.haha.perflib.** { *; }</option>
+ <option>-dontwarn javax.annotation.**</option>
+ <option>-optimizations !code/allocation/variable</option>
+ </options>
+ <libs>
+ <lib>${java.home}/lib/rt.jar</lib>
+ </libs>
+ </configuration>
+ </plugin>
</plugins>
</build>
diff --git a/src/main/java/com/android/annotations b/src/main/java/com/android/annotations
new file mode 120000
index 0000000..6b874ff
--- /dev/null
+++ b/src/main/java/com/android/annotations
@@ -0,0 +1 @@
+../../../../../../android_platform_tool_base/annotations/src/main/java/com/android/annotations
\ No newline at end of file
diff --git a/src/main/java/com/android/tools/perflib/heap b/src/main/java/com/android/tools/perflib/heap
new file mode 120000
index 0000000..0751864
--- /dev/null
+++ b/src/main/java/com/android/tools/perflib/heap
@@ -0,0 +1 @@
+../../../../../../../android_platform_tool_base/perflib/src/main/java/com/android/tools/perflib/heap
\ No newline at end of file
diff --git a/src/main/java/gnu/trove b/src/main/java/gnu/trove
new file mode 120000
index 0000000..c505665
--- /dev/null
+++ b/src/main/java/gnu/trove
@@ -0,0 +1 @@
+../../../../trove/trove4j-1.1-sources.jar-unzipped_flattened
\ No newline at end of file
diff --git a/src/main/java/org/eclipse/mat/SnapshotException.java b/src/main/java/org/eclipse/mat/SnapshotException.java
deleted file mode 100644
index ec62224..0000000
--- a/src/main/java/org/eclipse/mat/SnapshotException.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat;
-
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.util.MessageUtil;
-
-/**
- * Exception used to indicate a problem different from the standard Java
- * exceptions while performing an operation on an snapshot.
- */
-public class SnapshotException extends Exception {
- private static final long serialVersionUID = 1L;
-
- /**
- * Create snapshot exception - should not be used except during
- * deserialization.
- */
- public SnapshotException() {
- }
-
- /**
- * Create snapshot exception with message and root cause.
- */
- public SnapshotException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Create snapshot exception with message only.
- */
- public SnapshotException(String message) {
- super(message);
- }
-
- /**
- * Create snapshot exception with root cause only.
- */
- public SnapshotException(Throwable cause) {
- super(cause);
- }
-
- public SnapshotException(Messages messages) {
- super(MessageUtil.format(messages));
- }
-
- /**
- * Wrap, if necessary, and return a SnapshotException.
- */
- public static final SnapshotException rethrow(Throwable e) {
- if (e instanceof RuntimeException) {
- // if we wrap an SnapshotException, pass the snapshot exception on
- if (((RuntimeException) e).getCause() instanceof SnapshotException) {
- return (SnapshotException) ((RuntimeException) e).getCause();
- }
- throw (RuntimeException) e;
- } else if (e instanceof SnapshotException) {
- return (SnapshotException) e;
- } else {
- return new SnapshotException(e);
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/ArrayInt.java b/src/main/java/org/eclipse/mat/collect/ArrayInt.java
deleted file mode 100644
index 1db2c73..0000000
--- a/src/main/java/org/eclipse/mat/collect/ArrayInt.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-import java.util.Arrays;
-
-public final class ArrayInt {
- int elements[];
- int size;
-
- public ArrayInt() {
- this(10);
- }
-
- public ArrayInt(int initialCapacity) {
- elements = new int[initialCapacity];
- size = 0;
- }
-
- public ArrayInt(int[] initialValues) {
- this(initialValues.length);
- System.arraycopy(initialValues, 0, elements, 0, initialValues.length);
- size = initialValues.length;
- }
-
- public ArrayInt(ArrayInt template) {
- this(template.size);
- System.arraycopy(template.elements, 0, elements, 0, template.size);
- size = template.size;
- }
-
- public void add(int element) {
- ensureCapacity(size + 1);
- elements[size++] = element;
- }
-
- public void addAll(int[] elements) {
- ensureCapacity(size + elements.length);
- System.arraycopy(elements, 0, this.elements, size, elements.length);
- size += elements.length;
- }
-
- public void addAll(ArrayInt template) {
- ensureCapacity(size + template.size);
- System.arraycopy(template.elements, 0, elements, size, template.size);
- size += template.size;
- }
-
- public int set(int index, int element) {
- if (index < 0 || index >= size) throw new ArrayIndexOutOfBoundsException(index);
-
- int oldValue = elements[index];
- elements[index] = element;
- return oldValue;
- }
-
- public int get(int index) {
- if (index < 0 || index >= size) throw new ArrayIndexOutOfBoundsException(index);
- return elements[index];
- }
-
- public int size() {
- return size;
- }
-
- public int[] toArray() {
- int[] result = new int[size];
- System.arraycopy(elements, 0, result, 0, size);
- return result;
- }
-
- public boolean isEmpty() {
- return size == 0;
- }
-
- public IteratorInt iterator() {
- return new IteratorInt() {
- int index = 0;
-
- public boolean hasNext() {
- return index < size;
- }
-
- public int next() {
- return elements[index++];
- }
- };
- }
-
- public void clear() {
- size = 0;
- }
-
- public long lastElement() {
- return elements[size - 1];
- }
-
- public long firstElement() {
- if (size == 0) throw new ArrayIndexOutOfBoundsException();
-
- return elements[0];
- }
-
- public void sort() {
- Arrays.sort(elements, 0, size);
- }
-
- // //////////////////////////////////////////////////////////////
- // implementation stuff
- // //////////////////////////////////////////////////////////////
-
- private void ensureCapacity(int minCapacity) {
- int oldCapacity = elements.length;
- if (minCapacity > oldCapacity) {
- int oldData[] = elements;
- int newCapacity = (oldCapacity * 3) / 2 + 1;
- if (newCapacity < minCapacity) newCapacity = minCapacity;
- elements = new int[newCapacity];
- System.arraycopy(oldData, 0, elements, 0, size);
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/ArrayIntBig.java b/src/main/java/org/eclipse/mat/collect/ArrayIntBig.java
deleted file mode 100644
index b4beb51..0000000
--- a/src/main/java/org/eclipse/mat/collect/ArrayIntBig.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-
-/**
- * This class simplifies the handling of growing int[] in a very fast and memory
- * efficient manner so that no slow collections must be used. However this class
- * is only fast on big int[] and not on small ones where you collect just a
- * couple of ints. The internal data is never copied during the process of
- * growing. Only with {@link #toArray} the data is copied to the result int[].
- */
-public final class ArrayIntBig implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private ArrayList<int[]> pages;
- private int[] page;
- private int length;
-
- /**
- * Create an <code>IntArray</code>. Memory consumption is equal to creating
- * a new <code>ArrayList</code>.
- */
- public ArrayIntBig() {
- pages = new ArrayList<int[]>();
- length = 0;
- }
-
- /**
- * Add int to <code>IntArray</code>.
- *
- * @param element int which should be added
- */
- public final void add(int element) {
- int index = (length++) & 0x3FF;
- if (index == 0) {
- pages.add(page = new int[0x400]);
- }
- page[index] = element;
- }
-
- /**
- * Add int[] to <code>IntArray</code>.
- *
- * @param elements int[] which should be added
- */
- public final void addAll(int[] elements) {
- int free = (length & 0x3FF);
- int bite = free == 0 ? 0 : Math.min(elements.length, 0x400 - free);
- if (bite > 0) {
- System.arraycopy(elements, 0, pages.get(length >> 10), length & 0x3FF, bite);
- length += bite;
- }
- int copied = bite;
- while (copied < elements.length) {
- pages.add(page = new int[0x400]);
- bite = Math.min(elements.length - copied, 0x400);
- System.arraycopy(elements, copied, page, 0, bite);
- copied += bite;
- length += bite;
- }
- }
-
- /**
- * Get int at index from <code>IntArray</code>.
- *
- * @param index index of int which should be returned
- * @return int at index
- * @throws IndexOutOfBoundsException
- */
- public final int get(int index) throws IndexOutOfBoundsException {
- if (index >= length) {
- throw new IndexOutOfBoundsException();
- }
- return pages.get(index >> 10)[index & 0x3FF];
- }
-
- /**
- * Get length of <code>IntArray</code>.
- *
- * @return length of <code>IntArray</code>
- */
- public final int length() {
- return length;
- }
-
- /**
- * Returns <tt>true</tt> if this list contains no elements.
- *
- * @return <tt>true</tt> if this list contains no elements.
- */
- public boolean isEmpty() {
- return length == 0;
- }
-
- /**
- * Get memory consumption of <code>IntArray</code>.
- *
- * @return memory consumption of <code>IntArray</code>
- */
- public final long consumption() {
- return ((long) pages.size()) << 12;
- }
-
- /**
- * Convert <code>IntArray</code> to int[]. This operation is the only one
- * where the internal data is copied. It is directly copied to the int[]
- * which is returned, so don't call this method more than once when done.
- *
- * @return int[] representing the <code>IntArray</code>
- */
- public final int[] toArray() {
- int[] elements = new int[length];
- int bite;
- int copied = 0;
- while (copied < length) {
- bite = Math.min(length - copied, 0x400);
- System.arraycopy(pages.get(copied >> 10), 0, elements, copied, bite);
- copied += bite;
- }
- return elements;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/ArrayIntCompressed.java b/src/main/java/org/eclipse/mat/collect/ArrayIntCompressed.java
deleted file mode 100644
index 675d41a..0000000
--- a/src/main/java/org/eclipse/mat/collect/ArrayIntCompressed.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-/**
- * This class compresses fixed-size int[] in a very fast and memory efficient
- * manner if many leading and/or trailing bits of the stored ints are not used
- * commonly. The internal data is never copied during the process of retrieving
- * or reconstructing objects of this class and allows for fast I/O writing and
- * reading of the underlying byte[]. Furthermore alomst no additinal data is
- * used beside the underlying byte[]. Thereby the memory consumption of this
- * data structure is kept at a minmum to build efficient int[] caches.
- */
-public class ArrayIntCompressed {
- private static final int BIT_LENGTH = 0x20;
-
- private byte[] data;
- private byte varyingBits;
- private byte trailingClearBits;
-
- /**
- * Create <code>IntArrayCompressed</code> from bytes formerly got from
- * {@link #toByteArray()}.
- *
- * @param bytes bytes formerly got from {@link #toByteArray()}
- */
- public ArrayIntCompressed(byte[] bytes) {
- // Take data structure
- data = bytes;
- varyingBits = data[0];
- trailingClearBits = data[1];
- }
-
- /**
- * Create <code>IntArrayCompressed</code> from number of ints to be stored,
- * the number of leading and trailing clear bits. Everything else is stored
- * in the internal data structure.
- *
- * @param size number of ints to be stored
- * @param leadingClearBits number of leading clear bits
- * @param trailingClearBits number of trailing clear bits
- */
- public ArrayIntCompressed(int size, int leadingClearBits, int trailingClearBits) {
- // Initialize data structure
- init(size, BIT_LENGTH - leadingClearBits - trailingClearBits, trailingClearBits);
- }
-
- /**
- * Create <code>IntArrayCompressed</code> from ints representing the data to
- * be stored in compressed form.
- *
- * @param ints ints representing the data to be stored in compressed form
- */
- public ArrayIntCompressed(int[] ints) {
- // Call more general constructor
- this(ints, 0, ints.length);
- }
-
- /**
- * Create <code>IntArrayCompressed</code> from ints representing the data to
- * be stored in compressed form (from offset to offset+length).
- *
- * @param ints ints representing the data to be stored in compressed form
- * @param offset offset from which on to compress the ints
- * @param length number of ints to compress from the given array
- */
- public ArrayIntCompressed(int[] ints, int offset, int length) {
- // Determine leading and trailing clear bits
- int mask = 0x0;
- for (int i = 0; i < length; i++) {
- mask |= ints[offset + i];
- }
- int leadingClearBits = 0;
- int trailingClearBits = 0;
- while (((mask & (1 << (BIT_LENGTH - leadingClearBits - 1))) == 0) && (leadingClearBits
- < BIT_LENGTH)) {
- leadingClearBits++;
- }
- while (((mask & (1 << trailingClearBits)) == 0) && (trailingClearBits < (BIT_LENGTH
- - leadingClearBits))) {
- trailingClearBits++;
- }
-
- // Initialize data structure
- init(length, BIT_LENGTH - leadingClearBits - trailingClearBits, trailingClearBits);
-
- // Store data
- for (int i = 0; i < length; i++) {
- set(i, ints[offset + i]);
- }
- }
-
- private void init(int size, int varyingBits, int trailingClearBits) {
- // Allocate memory for header and data structure and put decompression
- // information into header
- data = new byte[2 + (int) (((((long) size) * varyingBits) - 1) / 0x8) + 1];
- this.varyingBits = data[0] = (byte) varyingBits;
- this.trailingClearBits = data[1] = (byte) trailingClearBits;
- }
-
- /**
- * Set value at the given index.
- *
- * @param index index at which the value should be set
- * @param value value to be set at the given index
- */
- public void set(int index, int value) {
- value >>>= trailingClearBits;
- final long pos = (long) (index) * varyingBits;
- int idx = 2 + (int) (pos >>> 3);
- int off = ((int) (pos)) & 0x7;
- off += varyingBits;
- if (off > 0x8) {
- off -= 0x8;
- data[idx++] |= (byte) (value >>> off);
- while (off > 0x8) {
- off -= 0x8;
- data[idx++] = (byte) (value >>> off);
- }
- }
- data[idx] |= (byte) (value << (0x8 - off));
- }
-
- /**
- * Get value from the given index.
- *
- * @param index index at which the value should be set
- * @return value found at the given index
- */
- public int get(int index) {
- int value = 0;
- final long pos = (long) (index) * varyingBits;
- int idx = 2 + (int) (pos >>> 3);
- int off = ((int) (pos)) & 0x7;
- if ((off + varyingBits) > 0x8) {
- value = ((data[idx++] << off) & 0xff) >>> off;
- off += varyingBits - 0x8;
- while (off > 0x8) {
- value <<= 0x8;
- value |= data[idx++] & 0xff;
- off -= 0x8;
- }
- value <<= off;
- value |= (data[idx] & 0xff) >>> (0x8 - off);
- } else {
- value = ((data[idx] << off) & 0xff) >>> (0x8 - varyingBits);
- }
- return value << trailingClearBits;
- }
-
- /**
- * Get bytes representing the internal data structure with which an
- * <code>IntArrayCompressed</code> can be reconstructed.
- *
- * @return bytes representing the internal data structure with which an
- * <code>IntArrayCompressed</code> can be reconstructed
- */
- public byte[] toByteArray() {
- // Return data structure
- return data;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/ArrayLong.java b/src/main/java/org/eclipse/mat/collect/ArrayLong.java
deleted file mode 100644
index fe8ce1e..0000000
--- a/src/main/java/org/eclipse/mat/collect/ArrayLong.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-import java.util.Arrays;
-
-public final class ArrayLong {
- long elements[];
- int size;
-
- public ArrayLong() {
- this(10);
- }
-
- public ArrayLong(int initialCapacity) {
- elements = new long[initialCapacity];
- size = 0;
- }
-
- public ArrayLong(long[] initialValues) {
- this(initialValues.length);
- System.arraycopy(initialValues, 0, elements, 0, initialValues.length);
- size = initialValues.length;
- }
-
- public ArrayLong(ArrayLong template) {
- this(template.size);
- System.arraycopy(template.elements, 0, elements, 0, template.size);
- size = template.size;
- }
-
- public void add(long element) {
- ensureCapacity(size + 1);
- elements[size++] = element;
- }
-
- public void addAll(long[] elements) {
- ensureCapacity(size + elements.length);
- System.arraycopy(elements, 0, this.elements, size, elements.length);
- size += elements.length;
- }
-
- public void addAll(ArrayLong template) {
- ensureCapacity(size + template.size);
- System.arraycopy(template.elements, 0, elements, size, template.size);
- size += template.size;
- }
-
- public long set(int index, long element) {
- if (index < 0 || index >= size) throw new ArrayIndexOutOfBoundsException(index);
-
- long oldValue = elements[index];
- elements[index] = element;
- return oldValue;
- }
-
- public long get(int index) {
- if (index < 0 || index >= size) throw new ArrayIndexOutOfBoundsException(index);
- return elements[index];
- }
-
- public int size() {
- return size;
- }
-
- public long[] toArray() {
- long[] result = new long[size];
- System.arraycopy(elements, 0, result, 0, size);
- return result;
- }
-
- public boolean isEmpty() {
- return size == 0;
- }
-
- public IteratorLong iterator() {
- return new IteratorLong() {
- int index = 0;
-
- public boolean hasNext() {
- return index < size;
- }
-
- public long next() {
- return elements[index++];
- }
- };
- }
-
- public void clear() {
- size = 0;
- }
-
- public long lastElement() {
- return elements[size - 1];
- }
-
- public long firstElement() {
- if (size == 0) throw new ArrayIndexOutOfBoundsException();
-
- return elements[0];
- }
-
- public void sort() {
- Arrays.sort(elements, 0, size);
- }
-
- // //////////////////////////////////////////////////////////////
- // implementation stuff
- // //////////////////////////////////////////////////////////////
-
- private void ensureCapacity(int minCapacity) {
- int oldCapacity = elements.length;
- if (minCapacity > oldCapacity) {
- long oldData[] = elements;
- int newCapacity = (oldCapacity * 3) / 2 + 1;
- if (newCapacity < minCapacity) newCapacity = minCapacity;
- elements = new long[newCapacity];
- System.arraycopy(oldData, 0, elements, 0, size);
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/ArrayLongCompressed.java b/src/main/java/org/eclipse/mat/collect/ArrayLongCompressed.java
deleted file mode 100644
index e9099b8..0000000
--- a/src/main/java/org/eclipse/mat/collect/ArrayLongCompressed.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-/**
- * This class compresses fixed-size long[] in a very fast and memory efficient
- * manner if many leading and/or trailing bits of the stored longs are not used
- * commonly. The internal data is never copied during the process of retrieving
- * or reconstructing objects of this class and allows for fast I/O writing and
- * reading of the underlying byte[]. Furthermore alomst no additinal data is
- * used beside the underlying byte[]. Thereby the memory consumption of this
- * data structure is kept at a minmum to build efficient long[] caches.
- */
-public class ArrayLongCompressed {
- private static final int BIT_LENGTH = 0x40;
-
- private byte[] data;
- private byte varyingBits;
- private byte trailingClearBits;
-
- /**
- * Create <code>LongArrayCompressed</code> from bytes formerly got from
- * {@link #toByteArray()}.
- *
- * @param bytes bytes formerly got from {@link #toByteArray()}
- */
- public ArrayLongCompressed(byte[] bytes) {
- // Take data structure
- data = bytes;
- varyingBits = data[0];
- trailingClearBits = data[1];
- }
-
- /**
- * Create <code>LongArrayCompressed</code> from number of longs to be
- * stored, the number of leading and trailing clear bits. Everything else is
- * stored in the internal data structure.
- *
- * @param size number of longs to be stored
- * @param leadingClearBits number of leading clear bits
- * @param trailingClearBits number of trailing clear bits
- */
- public ArrayLongCompressed(int size, int leadingClearBits, int trailingClearBits) {
- // Initialize data structure
- init(size, BIT_LENGTH - leadingClearBits - trailingClearBits, trailingClearBits);
- }
-
- /**
- * Create <code>LongArrayCompressed</code> from longs representing the data
- * to be stored in compressed form.
- *
- * @param longs longs representing the data to be stored in compressed form
- */
- public ArrayLongCompressed(long[] longs) {
- // Call more general constructor
- this(longs, 0, longs.length);
- }
-
- /**
- * Create <code>LongArrayCompressed</code> from longs representing the data
- * to be stored in compressed form (from offset to offset+length).
- *
- * @param longs longs representing the data to be stored in compressed form
- * @param offset offset from which on to compress the longs
- * @param length number of longs to compress from the given array
- */
- public ArrayLongCompressed(long[] longs, int offset, int length) {
- // Determine leading and trailing clear bits
- long mask = 0x0;
- for (int i = 0; i < length; i++) {
- mask |= longs[offset + i];
- }
- int leadingClearBits = 0;
- int trailingClearBits = 0;
- while (((mask & (1 << (BIT_LENGTH - leadingClearBits - 1))) == 0) && (leadingClearBits
- < BIT_LENGTH)) {
- leadingClearBits++;
- }
- while (((mask & (1 << trailingClearBits)) == 0) && (trailingClearBits < (BIT_LENGTH
- - leadingClearBits))) {
- trailingClearBits++;
- }
-
- // Initialize data structure
- init(length, BIT_LENGTH - leadingClearBits - trailingClearBits, trailingClearBits);
-
- // Store data
- for (int i = 0; i < length; i++) {
- set(i, longs[offset + i]);
- }
- }
-
- private void init(int size, int varyingBits, int trailingClearBits) {
- // Allocate memory for header and data structure and put decompression
- // information into header
- data = new byte[2 + (int) (((((long) size) * varyingBits) - 1) / 0x8) + 1];
- this.varyingBits = data[0] = (byte) varyingBits;
- this.trailingClearBits = data[1] = (byte) trailingClearBits;
- }
-
- /**
- * Set value at the given index.
- *
- * @param index index at which the value should be set
- * @param value value to be set at the given index
- */
- public void set(int index, long value) {
- value >>>= trailingClearBits;
- final long pos = (long) (index) * varyingBits;
- int idx = 2 + (int) (pos >>> 3);
- int off = ((int) (pos)) & 0x7;
- off += varyingBits;
- if (off > 0x8) {
- off -= 0x8;
- data[idx++] |= (byte) (value >>> off);
- while (off > 0x8) {
- off -= 0x8;
- data[idx++] = (byte) (value >>> off);
- }
- }
- data[idx] |= (byte) (value << (0x8 - off));
- }
-
- /**
- * Get value from the given index.
- *
- * @param index index at which the value should be set
- * @return value found at the given index
- */
- public long get(int index) {
- long value = 0;
- final long pos = (long) (index) * varyingBits;
- int idx = 2 + (int) (pos >>> 3);
- int off = ((int) (pos)) & 0x7;
- if ((off + varyingBits) > 0x8) {
- value = ((data[idx++] << off) & 0xff) >>> off;
- off += varyingBits - 0x8;
- while (off > 0x8) {
- value <<= 0x8;
- value |= data[idx++] & 0xff;
- off -= 0x8;
- }
- value <<= off;
- value |= (data[idx] & 0xff) >>> (0x8 - off);
- } else {
- value = ((data[idx] << off) & 0xff) >>> (0x8 - varyingBits);
- }
- return value << trailingClearBits;
- }
-
- /**
- * Get bytes representing the internal data structure with which an
- * <code>LongArrayCompressed</code> can be reconstructed.
- *
- * @return bytes representing the internal data structure with which an
- * <code>LongArrayCompressed</code> can be reconstructed
- */
- public byte[] toByteArray() {
- // Return data structure
- return data;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/ArrayUtils.java b/src/main/java/org/eclipse/mat/collect/ArrayUtils.java
deleted file mode 100644
index 518ebe5..0000000
--- a/src/main/java/org/eclipse/mat/collect/ArrayUtils.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-public class ArrayUtils {
-
- /**
- * Sorts the keys in an increasing order. Elements key[i] and values[i] are
- * always swapped together in the corresponding arrays.
- * <p>
- * A mixture of several sorting algorithms is used:
- * <p>
- * A radix sort performs better on the numeric data we sort, but requires
- * additional storage to perform the sorting. Therefore only the
- * not-very-large parts produced by a quick sort are sorted with radix sort.
- * An insertion sort is used to sort the smallest arrays, where the the
- * overhead of the radix sort is also bigger
- */
- public static void sort(int[] keys, int[] values) {
- hybridsort(keys, values, 0, keys.length - 1);
- }
-
- /**
- * Sorts the keys in an decreasing order. Elements key[i] and values[i] are
- * always swapped together in the corresponding arrays.
- * <p>
- * A mixture of several sorting algorithms is used:
- * <p>
- * A radix sort performs better on the numeric data we sort, but requires
- * additional storage to perform the sorting. Therefore only the
- * not-very-large parts produced by a quick sort are sorted with radix sort.
- * An insertion sort is used to sort the smallest arrays, where the the
- * overhead of the radix sort is also bigger
- */
- public static void sortDesc(long[] keys, int[] values) {
- hybridsortDesc(keys, values, null, null, 0, keys.length - 1);
- }
-
- /**
- * Sorts the keys in an decreasing order. Elements key[i] and values[i] are
- * always swapped together in the corresponding arrays.
- * <p>
- * A mixture of several sorting algorithms is used:
- * <p>
- * A radix sort performs better on the numeric data we sort, but requires
- * additional storage to perform the sorting. Therefore only the
- * not-very-large parts produced by a quick sort are sorted with radix sort.
- * An insertion sort is used to sort the smallest arrays, where the the
- * overhead of the radix sort is also bigger
- * <p>
- * This version of the method allows the temporarily needed arrays for the
- * radix sort to be provided externally - tempa and tempb. This saves
- * unnecessary array creation and cleanup
- */
- public static void sortDesc(long[] a, int[] b, long[] tmpa, int[] tmpb) {
- hybridsortDesc(a, b, tmpa, tmpb, 0, a.length - 1);
- }
-
- /**
- * Sorts a range from the keys in an increasing order. Elements key[i] and
- * values[i] are always swapped together in the corresponding arrays.
- * <p>
- * A mixture of several sorting algorithms is used:
- * <p>
- * A radix sort performs better on the numeric data we sort, but requires
- * additional storage to perform the sorting. Therefore only the
- * not-very-large parts produced by a quick sort are sorted with radix sort.
- * An insertion sort is used to sort the smallest arrays, where the the
- * overhead of the radix sort is also bigger
- */
- public static void sort(int[] keys, int[] values, int offset, int length) {
- hybridsort(keys, values, offset, offset + length - 1);
- }
-
- /*
- * PRIVATE METHODS IMPLEMENTING THE SORTING
- */
-
- private static void swap(int keys[], int values[], int a, int b) {
- // swap the keys
- int tmp = keys[a];
- keys[a] = keys[b];
- keys[b] = tmp;
-
- // swap the values
- tmp = values[a];
- values[a] = values[b];
- values[b] = tmp;
- }
-
- private static void swap(long keys[], int values[], int a, int b) {
- // swap the keys
- long tmpKey = keys[a];
- keys[a] = keys[b];
- keys[b] = tmpKey;
-
- // swap the values
- int tmpValue = values[a];
- values[a] = values[b];
- values[b] = tmpValue;
- }
-
- private static int median(int x[], int pos1, int pos2, int pos3) {
- int v1 = x[pos1];
- int v2 = x[pos2];
- int v3 = x[pos3];
-
- if (v1 < v2) {
- if (v2 <= v3) {
- return pos2;
- } else {
- return v1 < v3 ? pos3 : pos1;
- }
- }
-
- /* else -> v1 > v2 */
- if (v1 <= v3) {
- return pos1;
- } else {
- return v2 < v3 ? pos3 : pos2;
- }
- }
-
- private static int median(long x[], int pos1, int pos2, int pos3) {
- long v1 = x[pos1];
- long v2 = x[pos2];
- long v3 = x[pos3];
-
- if (v1 < v2) {
- if (v2 <= v3) {
- return pos2;
- } else {
- return v1 < v3 ? pos3 : pos1;
- }
- }
-
- /* else -> v1 > v2 */
- if (v1 <= v3) {
- return pos1;
- } else {
- return v2 < v3 ? pos3 : pos2;
- }
- }
-
- private static int[] split(int[] keys, int[] values, int left, int right) {
- // just take the median of the middle key and the two border keys
- int splittingIdx = median(keys, left, right, left + ((right - left) >> 1));
- int splittingValue = keys[splittingIdx];
-
- // move splitting element first
- swap(keys, values, left, splittingIdx);
-
- int i = left;
- int c = 0; // number of elements equal to splittingValue
- for (int j = left + 1; j <= right; j++) {
- if (keys[j] < splittingValue) {
- i++;
- swap(keys, values, i, j);
-
- // if there are duplicates, keep them next to each other
- if (c > 0) swap(keys, values, i + c, j);
- } else if (keys[j] == splittingValue) {
- c++;
- swap(keys, values, i + c, j);
- }
- }
- swap(keys, values, left, i);
-
- return new int[] { i, i + c };
- }
-
- private static int[] splitDesc(long[] keys, int[] values, int left, int right) {
- // just take the median of the middle key and the two border keys
- int splittingIdx = median(keys, left, right, left + ((right - left) >> 1));
- long splittingValue = keys[splittingIdx];
-
- // move splitting element first
- swap(keys, values, left, splittingIdx);
-
- int i = left;
- int c = 0; // number of elements equal to splittingValue
- for (int j = left + 1; j <= right; j++) {
- if (keys[j] > splittingValue) {
- i++;
- swap(keys, values, i, j);
-
- // if there are duplicates, keep them next to each other
- if (c > 0) swap(keys, values, i + c, j);
- } else if (keys[j] == splittingValue) {
- c++;
- swap(keys, values, i + c, j);
- }
- }
- swap(keys, values, left, i);
-
- return new int[] { i, i + c };
- }
-
- private static void hybridsort(int[] keys, int[] values, int left, int right) {
- while (right - left >= 1) {
- if (right - left < 5000000) {
- radixsort(keys, values, left, right - left + 1);
- break;
- } else {
- // split the array - the elements between i[0] and i[1] are
- // equal.
- // the elements on the left are smaller, on the right - bigger
- int[] i = split(keys, values, left, right);
-
- int sizeLeft = i[0] - left;
- int sizeRight = right - i[1];
-
- // Limit recursion depth by doing the smaller side first
- if (sizeLeft <= sizeRight) {
- // sort all keys smaller than keys[i]
- hybridsort(keys, values, left, i[0] - 1);
- // then loop to do all keys bigger than keys[i]
- left = i[1] + 1;
- } else {
- // sort all keys bigger than keys[i]
- hybridsort(keys, values, i[1] + 1, right);
- // then loop to do all keys smaller than keys[i]
- right = i[0] - 1;
- }
- }
- }
- }
-
- private static void hybridsortDesc(long[] keys, int[] values, long[] tmpKeys, int[] tmpValues,
- int left, int right) {
- while (right - left >= 1) {
- if (right - left < 5000000) {
- // use insert sort on the small ones
- // to avoid the loop in radix sort
- if (right - left < 12) {
- for (int i = left; i <= right; i++)
- for (int j = i; j > left && keys[j - 1] < keys[j]; j--)
- swap(keys, values, j, j - 1);
- return;
- }
- radixsortDesc(keys, values, tmpKeys, tmpValues, left, right - left + 1);
- break;
- } else {
- // split the array - the elements between i[0] and i[1] are
- // equal.
- // the elements on the left are bigger, on the right - smaller
- int[] i = splitDesc(keys, values, left, right);
-
- int sizeLeft = i[0] - left;
- int sizeRight = right - i[1];
-
- // Limit recursion depth by doing the smaller side first
- if (sizeLeft <= sizeRight) {
- // sort all keys bigger than keys[i]
- hybridsortDesc(keys, values, tmpKeys, tmpValues, left, i[0] - 1);
- // then loop to sort all keys smaller than keys[i]
- left = i[1] + 1;
- } else {
- // sort all keys smaller than keys[i]
- hybridsortDesc(keys, values, tmpKeys, tmpValues, i[1] + 1, right);
- // then loop to sort all keys bigger than keys[i]
- right = i[0] - 1;
- }
- }
- }
- }
-
- private static void radixsort(int[] keys, int[] values, int offset, int length) {
- int[] tempKeys = new int[length];
- int[] tempValues = new int[length];
- countsort(keys, tempKeys, values, tempValues, offset, 0, length, 0);
- countsort(tempKeys, keys, tempValues, values, 0, offset, length, 1);
- countsort(keys, tempKeys, values, tempValues, offset, 0, length, 2);
- countsort(tempKeys, keys, tempValues, values, 0, offset, length, 3);
- }
-
- private static void radixsortDesc(long[] keys, int[] values, long[] tempKeys, int[] tempValues,
- int offset, int length) {
- if (tempKeys == null) tempKeys = new long[length];
- if (tempValues == null) tempValues = new int[length];
- countsortDesc(keys, tempKeys, values, tempValues, offset, 0, length, 0);
- countsortDesc(tempKeys, keys, tempValues, values, 0, offset, length, 1);
- countsortDesc(keys, tempKeys, values, tempValues, offset, 0, length, 2);
- countsortDesc(tempKeys, keys, tempValues, values, 0, offset, length, 3);
- countsortDesc(keys, tempKeys, values, tempValues, offset, 0, length, 4);
- countsortDesc(tempKeys, keys, tempValues, values, 0, offset, length, 5);
- countsortDesc(keys, tempKeys, values, tempValues, offset, 0, length, 6);
- countsortDesc(tempKeys, keys, tempValues, values, 0, offset, length, 7);
- }
-
- private static void countsort(int[] srcKeys, int[] destKeys, int[] srcValues, int[] destValues,
- int srcOffset, int trgOffset, int length, int sortByte) {
- int[] count = new int[256];
- int[] index = new int[256];
-
- int shiftBits = 8 * sortByte;
- int srcEnd = srcOffset + length;
-
- for (int i = srcOffset; i < srcEnd; i++)
- count[((srcKeys[i] >> (shiftBits)) & 0xff)]++;
-
- if (sortByte == 3) {
- // Sign byte, so sort 128..255 0..127
- /* index[128] = 0 */
- for (int i = 129; i < 256; i++)
- index[i] = index[i - 1] + count[i - 1];
- index[0] = index[255] + count[255];
- for (int i = 1; i < 128; i++)
- index[i] = index[i - 1] + count[i - 1];
- } else {
- /* index[0] = 0 */
- for (int i = 1; i < 256; i++)
- index[i] = index[i - 1] + count[i - 1];
- }
-
- for (int i = srcOffset; i < srcEnd; i++) {
- int idx = ((srcKeys[i] >> (shiftBits)) & 0xff);
- destValues[trgOffset + index[idx]] = srcValues[i];
- destKeys[trgOffset + index[idx]++] = srcKeys[i];
- }
- }
-
- private static void countsortDesc(long[] srcKeys, long[] destKeys, int[] srcValues,
- int[] destValues, int srcOffset, int trgOffset, int length, int sortByte) {
- int[] count = new int[256];
- int[] index = new int[256];
-
- int shiftBits = 8 * sortByte;
- int srcEnd = srcOffset + length;
-
- for (int i = srcOffset; i < srcEnd; i++)
- count[(int) ((srcKeys[i] >> (shiftBits)) & 0xff)]++;
-
- if (sortByte == 7) {
- // Sign byte, so sort 127..0 255..128
- /* index[127] = 0 */
- for (int i = 126; i >= 0; i--)
- index[i] = index[i + 1] + count[i + 1];
- index[255] = index[0] + count[0];
- for (int i = 254; i >= 128; i--)
- index[i] = index[i + 1] + count[i + 1];
- } else {
- /* index[255] = 0 */
- for (int i = 254; i >= 0; i--)
- index[i] = index[i + 1] + count[i + 1];
- }
-
- for (int i = srcOffset; i < srcEnd; i++) {
- int idx = (int) ((srcKeys[i] >> (shiftBits)) & 0xff);
- destValues[trgOffset + index[idx]] = srcValues[i];
- destKeys[trgOffset + index[idx]++] = srcKeys[i];
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/BitField.java b/src/main/java/org/eclipse/mat/collect/BitField.java
deleted file mode 100644
index 1909652..0000000
--- a/src/main/java/org/eclipse/mat/collect/BitField.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-import java.io.Serializable;
-
-/**
- * This class manages huge bit fields. It is much faster than
- * {@link java.util.BitSet} and was specifically developed to be used with huge
- * bit sets in ISnapshot (e.g. needed in virtual GC traces). Out of performance
- * reasons no method does any parameter checking, i.e. only valid values are
- * expected.
- */
-public final class BitField implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private int[] bits;
-
- /**
- * Creates a bit field with the given number of bits. Size is expected to be
- * positive - out of performance reasons no checks are done!
- */
- public BitField(int size) {
- bits = new int[(((size) - 1) >>> 0x5) + 1];
- }
-
- /**
- * Sets the bit on the given index. Index is expected to be in range - out
- * of performance reasons no checks are done!
- */
- public final void set(int index) {
- bits[index >>> 0x5] |= (1 << (index & 0x1f));
- }
-
- /**
- * Clears the bit on the given index. Index is expected to be in range - out
- * of performance reasons no checks are done!
- */
- public final void clear(int index) {
- bits[index >>> 0x5] &= ~(1 << (index & 0x1f));
- }
-
- /**
- * Gets the bit on the given index. Index is expected to be in range - out
- * of performance reasons no checks are done!
- */
- public final boolean get(int index) {
- return (bits[index >>> 0x5] & (1 << (index & 0x1f))) != 0;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/HashMapIntLong.java b/src/main/java/org/eclipse/mat/collect/HashMapIntLong.java
deleted file mode 100644
index 150af8f..0000000
--- a/src/main/java/org/eclipse/mat/collect/HashMapIntLong.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-public final class HashMapIntLong implements Serializable {
- public interface Entry {
- int getKey();
-
- long getValue();
- }
-
- private static NoSuchElementException noSuchElementException = new NoSuchElementException(
- "This is static exception, there is no stack trace available. It is thrown by get() method.");
- //$NON-NLS-1$
-
- private static final long serialVersionUID = 1L;
-
- private int capacity;
- private int step;
- private int limit;
- private int size;
- private boolean[] used;
- private int[] keys;
- private long[] values;
-
- public HashMapIntLong() {
- this(10);
- }
-
- public HashMapIntLong(int initialCapacity) {
- init(initialCapacity);
- }
-
- public boolean put(int key, long value) {
- if (size == limit) resize(capacity << 1);
-
- int hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- values[hash] = value;
- return true;
- }
- hash = (hash + step) % capacity;
- }
- used[hash] = true;
- keys[hash] = key;
- values[hash] = value;
- size++;
-
- return false;
- }
-
- public boolean remove(int key) {
- int hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- used[hash] = false;
- size--;
- // Re-hash all follow-up entries anew; Do not fiddle with the
- // capacity limit (75 %) otherwise this code may loop forever
- hash = (hash + step) % capacity;
- while (used[hash]) {
- key = keys[hash];
- used[hash] = false;
- int newHash = (key & Integer.MAX_VALUE) % capacity;
- while (used[newHash]) {
- newHash = (newHash + step) % capacity;
- }
- used[newHash] = true;
- keys[newHash] = key;
- values[newHash] = values[hash];
- hash = (hash + step) % capacity;
- }
- return true;
- }
- hash = (hash + step) % capacity;
- }
-
- return false;
- }
-
- public boolean containsKey(int key) {
- int hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- return true;
- }
- hash = (hash + step) % capacity;
- }
- return false;
- }
-
- public long get(int key) {
- int hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- return values[hash];
- }
- hash = (hash + step) % capacity;
- }
-
- throw noSuchElementException;
- }
-
- public int[] getAllKeys() {
- int[] array = new int[size];
- int j = 0;
- for (int i = 0; i < used.length; i++) {
- if (used[i]) {
- array[j++] = keys[i];
- }
- }
- return array;
- }
-
- public int size() {
- return size;
- }
-
- public boolean isEmpty() {
- return size() == 0;
- }
-
- public void clear() {
- size = 0;
- used = new boolean[capacity];
- }
-
- public IteratorInt keys() {
- return new IteratorInt() {
- int n = 0;
- int i = -1;
-
- public boolean hasNext() {
- return n < size;
- }
-
- public int next() throws NoSuchElementException {
- while (++i < used.length) {
- if (used[i]) {
- n++;
- return keys[i];
- }
- }
- throw new NoSuchElementException();
- }
- };
- }
-
- public IteratorLong values() {
- return new IteratorLong() {
- int n = 0;
- int i = -1;
-
- public boolean hasNext() {
- return n < size;
- }
-
- public long next() throws NoSuchElementException {
- while (++i < used.length) {
- if (used[i]) {
- n++;
- return values[i];
- }
- }
- throw new NoSuchElementException();
- }
- };
- }
-
- public Iterator<Entry> entries() {
- return new Iterator<Entry>() {
- int n = 0;
- int i = -1;
-
- public boolean hasNext() {
- return n < size;
- }
-
- public Entry next() throws NoSuchElementException {
- while (++i < used.length) {
- if (used[i]) {
- n++;
- return new Entry() {
- public int getKey() {
- return keys[i];
- }
-
- public long getValue() {
- return values[i];
- }
- };
- }
- }
- throw new NoSuchElementException();
- }
-
- public void remove() throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- public long[] getAllValues() {
- long[] a = new long[size];
-
- int index = 0;
- for (int ii = 0; ii < values.length; ii++) {
- if (used[ii]) a[index++] = values[ii];
- }
-
- return a;
- }
-
- private void init(int initialCapacity) {
- capacity = PrimeFinder.findNextPrime(initialCapacity);
- step = Math.max(1, PrimeFinder.findPrevPrime(initialCapacity / 3));
- limit = (int) (capacity * 0.75);
- clear();
- keys = new int[capacity];
- values = new long[capacity];
- }
-
- private void resize(int newCapacity) {
- int oldSize = size;
- boolean[] oldUsed = used;
- int[] oldKeys = keys;
- long[] oldValues = values;
- init(newCapacity);
- int key, hash;
- for (int i = 0; i < oldUsed.length; i++) {
- if (oldUsed[i]) {
- key = oldKeys[i];
- hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- hash = (hash + step) % capacity;
- }
- used[hash] = true;
- keys[hash] = key;
- values[hash] = oldValues[i];
- }
- }
- size = oldSize;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/HashMapIntObject.java b/src/main/java/org/eclipse/mat/collect/HashMapIntObject.java
deleted file mode 100644
index 34d0e8e..0000000
--- a/src/main/java/org/eclipse/mat/collect/HashMapIntObject.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.reflect.Array;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-public final class HashMapIntObject<E> implements Serializable {
- public interface Entry<E> {
- int getKey();
-
- E getValue();
- }
-
- private static final long serialVersionUID = 2L;
-
- private int capacity;
- private int step;
- private int limit;
- private int size;
- private transient boolean[] used;
- private transient int[] keys;
- private transient E[] values;
-
- public HashMapIntObject() {
- this(10);
- }
-
- public HashMapIntObject(int initialCapacity) {
- init(initialCapacity);
- }
-
- public E put(int key, E value) {
- if (size == limit) resize(capacity << 1);
-
- int hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- E oldValue = values[hash];
- values[hash] = value;
- return oldValue;
- }
- hash = (hash + step) % capacity;
- }
- used[hash] = true;
- keys[hash] = key;
- values[hash] = value;
- size++;
- return null;
- }
-
- public E remove(int key) {
- int hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- E oldValue = values[hash];
- used[hash] = false;
- size--;
- // Re-hash all follow-up entries anew; Do not fiddle with the
- // capacity limit (75 %) otherwise this code may loop forever
- hash = (hash + step) % capacity;
- while (used[hash]) {
- key = keys[hash];
- used[hash] = false;
- int newHash = (key & Integer.MAX_VALUE) % capacity;
- while (used[newHash]) {
- newHash = (newHash + step) % capacity;
- }
- used[newHash] = true;
- keys[newHash] = key;
- values[newHash] = values[hash];
- hash = (hash + step) % capacity;
- }
- return oldValue;
- }
- hash = (hash + step) % capacity;
- }
- return null;
- }
-
- public boolean containsKey(int key) {
- int hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- return true;
- }
- hash = (hash + step) % capacity;
- }
- return false;
- }
-
- public E get(int key) {
- int hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- return values[hash];
- }
- hash = (hash + step) % capacity;
- }
- return null;
- }
-
- public int[] getAllKeys() {
- int[] array = new int[size];
- int j = 0;
- for (int i = 0; i < used.length; i++) {
- if (used[i]) {
- array[j++] = keys[i];
- }
- }
- return array;
- }
-
- public Object[] getAllValues() {
- Object[] array = new Object[size];
- int index = 0;
- for (int ii = 0; ii < used.length; ii++) {
- if (used[ii]) array[index++] = values[ii];
- }
- return array;
- }
-
- @SuppressWarnings("unchecked") public <T> T[] getAllValues(T[] a) {
- if (a.length < size) a = (T[]) Array.newInstance(a.getClass().getComponentType(), size);
-
- int index = 0;
- for (int ii = 0; ii < used.length; ii++) {
- if (used[ii]) a[index++] = (T) values[ii];
- }
-
- if (a.length > size) a[size] = null;
- return a;
- }
-
- public int size() {
- return size;
- }
-
- public boolean isEmpty() {
- return size() == 0;
- }
-
- public void clear() {
- size = 0;
- used = new boolean[capacity];
- }
-
- public IteratorInt keys() {
- return new IteratorInt() {
- int n = 0;
- int i = -1;
-
- public boolean hasNext() {
- return n < size;
- }
-
- public int next() throws NoSuchElementException {
- while (++i < used.length) {
- if (used[i]) {
- n++;
- return keys[i];
- }
- }
- throw new NoSuchElementException();
- }
- };
- }
-
- public Iterator<E> values() {
- return new Iterator<E>() {
- int n = 0;
- int i = -1;
-
- public boolean hasNext() {
- return n < size;
- }
-
- public E next() throws NoSuchElementException {
- while (++i < used.length) {
- if (used[i]) {
- n++;
- return values[i];
- }
- }
- throw new NoSuchElementException();
- }
-
- public void remove() throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- public Iterator<Entry<E>> entries() {
- return new Iterator<Entry<E>>() {
- int n = 0;
- int i = -1;
-
- public boolean hasNext() {
- return n < size;
- }
-
- public Entry<E> next() throws NoSuchElementException {
- while (++i < used.length) {
- if (used[i]) {
- n++;
- return new Entry<E>() {
- public int getKey() {
- return keys[i];
- }
-
- public E getValue() {
- return values[i];
- }
- };
- }
- }
- throw new NoSuchElementException();
- }
-
- public void remove() throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- @SuppressWarnings("unchecked") private void init(int initialCapacity) {
- capacity = PrimeFinder.findNextPrime(initialCapacity);
- step = Math.max(1, PrimeFinder.findPrevPrime(initialCapacity / 3));
- limit = (int) (capacity * 0.75);
- clear();
- keys = new int[capacity];
- // This cast is ok as long as nobody assigns the field values to a field
- // of type <E>[] (values is of type Object[] and an assignment would
- // lead to a ClassCastException). This cast here is performed to extract
- // the array elements later without additional casts in the other calls.
- values = (E[]) new Object[capacity];
- }
-
- private void resize(int newCapacity) {
- int oldSize = size;
- boolean[] oldUsed = used;
- int[] oldKeys = keys;
- E[] oldValues = values;
- init(newCapacity);
- int key, hash;
- for (int i = 0; i < oldUsed.length; i++) {
- if (oldUsed[i]) {
- key = oldKeys[i];
- hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- hash = (hash + step) % capacity;
- }
- used[hash] = true;
- keys[hash] = key;
- values[hash] = oldValues[i];
- }
- }
- size = oldSize;
- }
-
- private void writeObject(ObjectOutputStream stream) throws IOException {
- stream.defaultWriteObject();
- for (int ii = 0; ii < used.length; ii++) {
- if (used[ii]) {
- stream.writeInt(keys[ii]);
- stream.writeObject(values[ii]);
- }
- }
- }
-
- @SuppressWarnings("unchecked") private void readObject(ObjectInputStream stream)
- throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
-
- // compat: serialized maps could contain old step factor
- step = Math.max(1, PrimeFinder.findPrevPrime(capacity / 3));
-
- used = new boolean[capacity];
- keys = new int[capacity];
- values = (E[]) new Object[capacity];
-
- for (int ii = 0; ii < size; ii++)
- putQuick(stream.readInt(), (E) stream.readObject());
- }
-
- private void putQuick(int key, E value) {
- int hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- values[hash] = value;
- return;
- }
- hash = (hash + step) % capacity;
- }
- used[hash] = true;
- keys[hash] = key;
- values[hash] = value;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/HashMapLongObject.java b/src/main/java/org/eclipse/mat/collect/HashMapLongObject.java
deleted file mode 100644
index 4a4067b..0000000
--- a/src/main/java/org/eclipse/mat/collect/HashMapLongObject.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-import java.io.Serializable;
-import java.lang.reflect.Array;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-public final class HashMapLongObject<E> implements Serializable {
- public interface Entry<E> {
- long getKey();
-
- E getValue();
- }
-
- private static final long serialVersionUID = 1L;
-
- private int capacity;
- private int step;
- private int limit;
- private int size;
- private boolean[] used;
- private long[] keys;
- private E[] values;
-
- public HashMapLongObject() {
- this(10);
- }
-
- public HashMapLongObject(int initialCapacity) {
- init(initialCapacity);
- }
-
- public E put(long key, E value) {
- if (size == limit) resize(capacity << 1);
-
- int hash = hash(key) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- E oldValue = values[hash];
- values[hash] = value;
- return oldValue;
- }
- hash = (hash + step) % capacity;
- }
- used[hash] = true;
- keys[hash] = key;
- values[hash] = value;
- size++;
- return null;
- }
-
- private int hash(long key) {
- return (int) (key & Integer.MAX_VALUE);
- }
-
- public E remove(long key) {
- int hash = hash(key) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- E oldValue = values[hash];
- used[hash] = false;
- size--;
- // Re-hash all follow-up entries anew; Do not fiddle with the
- // capacity limit (75 %) otherwise this code may loop forever
- hash = (hash + step) % capacity;
- while (used[hash]) {
- key = keys[hash];
- used[hash] = false;
- int newHash = hash(key) % capacity;
- while (used[newHash]) {
- newHash = (newHash + step) % capacity;
- }
- used[newHash] = true;
- keys[newHash] = key;
- values[newHash] = values[hash];
- hash = (hash + step) % capacity;
- }
- return oldValue;
- }
- hash = (hash + step) % capacity;
- }
- return null;
- }
-
- public boolean containsKey(long key) {
- int hash = hash(key) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- return true;
- }
- hash = (hash + step) % capacity;
- }
- return false;
- }
-
- public E get(long key) {
- int hash = hash(key) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- return values[hash];
- }
- hash = (hash + step) % capacity;
- }
- return null;
- }
-
- public long[] getAllKeys() {
- long[] array = new long[size];
- int j = 0;
- for (int i = 0; i < used.length; i++) {
- if (used[i]) {
- array[j++] = keys[i];
- }
- }
- return array;
- }
-
- public Object[] getAllValues() {
- Object[] array = new Object[size];
- int index = 0;
- for (int ii = 0; ii < used.length; ii++) {
- if (used[ii]) array[index++] = values[ii];
- }
- return array;
- }
-
- @SuppressWarnings("unchecked") public <T> T[] getAllValues(T[] a) {
- if (a.length < size) a = (T[]) Array.newInstance(a.getClass().getComponentType(), size);
-
- int index = 0;
- for (int ii = 0; ii < used.length; ii++) {
- if (used[ii]) a[index++] = (T) values[ii];
- }
-
- if (a.length > size) a[size] = null;
- return a;
- }
-
- public int size() {
- return size;
- }
-
- public boolean isEmpty() {
- return size() == 0;
- }
-
- public void clear() {
- size = 0;
- used = new boolean[capacity];
- }
-
- public IteratorLong keys() {
- return new IteratorLong() {
- int n = 0;
- int i = -1;
-
- public boolean hasNext() {
- return n < size;
- }
-
- public long next() throws NoSuchElementException {
- while (++i < used.length) {
- if (used[i]) {
- n++;
- return keys[i];
- }
- }
- throw new NoSuchElementException();
- }
- };
- }
-
- public Iterator<E> values() {
- return new Iterator<E>() {
- int n = 0;
- int i = -1;
-
- public boolean hasNext() {
- return n < size;
- }
-
- public E next() throws NoSuchElementException {
- while (++i < used.length) {
- if (used[i]) {
- n++;
- return values[i];
- }
- }
- throw new NoSuchElementException();
- }
-
- public void remove() throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- public Iterator<Entry<E>> entries() {
- return new Iterator<Entry<E>>() {
- int n = 0;
- int i = -1;
-
- public boolean hasNext() {
- return n < size;
- }
-
- public Entry<E> next() throws NoSuchElementException {
- while (++i < used.length) {
- if (used[i]) {
- n++;
- return new Entry<E>() {
- public long getKey() {
- return keys[i];
- }
-
- public E getValue() {
- return values[i];
- }
- };
- }
- }
- throw new NoSuchElementException();
- }
-
- public void remove() throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- @SuppressWarnings("unchecked") private void init(int initialCapacity) {
- capacity = PrimeFinder.findNextPrime(initialCapacity);
- step = Math.max(1, PrimeFinder.findPrevPrime(initialCapacity / 3));
- limit = (int) (capacity * 0.75);
- clear();
- keys = new long[capacity];
- // This cast is ok as long as nobody assigns the field values to a field
- // of type <E>[] (values is of type Object[] and an assignment would
- // lead to a ClassCastException). This cast here is performed to extract
- // the array elements later without additional casts in the other calls.
- values = (E[]) new Object[capacity];
- }
-
- private void resize(int newCapacity) {
- int oldSize = size;
- boolean[] oldUsed = used;
- long[] oldKeys = keys;
- E[] oldValues = values;
- init(newCapacity);
- long key;
- int hash;
- for (int i = 0; i < oldUsed.length; i++) {
- if (oldUsed[i]) {
- key = oldKeys[i];
- hash = hash(key) % capacity;
- while (used[hash]) {
- hash = (hash + step) % capacity;
- }
- used[hash] = true;
- keys[hash] = key;
- values[hash] = oldValues[i];
- }
- }
- size = oldSize;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/IteratorInt.java b/src/main/java/org/eclipse/mat/collect/IteratorInt.java
deleted file mode 100644
index af59b8f..0000000
--- a/src/main/java/org/eclipse/mat/collect/IteratorInt.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-public interface IteratorInt {
- boolean hasNext();
-
- int next();
-}
diff --git a/src/main/java/org/eclipse/mat/collect/IteratorLong.java b/src/main/java/org/eclipse/mat/collect/IteratorLong.java
deleted file mode 100644
index fa97678..0000000
--- a/src/main/java/org/eclipse/mat/collect/IteratorLong.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-public interface IteratorLong {
- boolean hasNext();
-
- long next();
-}
diff --git a/src/main/java/org/eclipse/mat/collect/PrimeFinder.java b/src/main/java/org/eclipse/mat/collect/PrimeFinder.java
deleted file mode 100644
index ed665e6..0000000
--- a/src/main/java/org/eclipse/mat/collect/PrimeFinder.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-/* package */class PrimeFinder {
- public static int findNextPrime(int floor) {
- boolean isPrime = false;
- while (!isPrime) {
- floor++;
- isPrime = true;
- int sqrt = (int) Math.sqrt(floor);
- for (int i = 2; i <= sqrt; i++) {
- if ((floor / i * i) == floor) {
- isPrime = false;
- }
- }
- }
- return floor;
- }
-
- public static int findPrevPrime(int ceil) {
- boolean isPrime = false;
- while (!isPrime) {
- ceil--;
- isPrime = true;
- int sqrt = (int) Math.sqrt(ceil);
- for (int i = 2; i <= sqrt; i++) {
- if ((ceil / i * i) == ceil) {
- isPrime = false;
- }
- }
- }
- return ceil;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/QueueInt.java b/src/main/java/org/eclipse/mat/collect/QueueInt.java
deleted file mode 100644
index ff5f5cc..0000000
--- a/src/main/java/org/eclipse/mat/collect/QueueInt.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-
-package org.eclipse.mat.collect;
-
-import org.eclipse.mat.hprof.Messages;
-
-/**
- * @since 0.8
- */
-public class QueueInt {
- int[] data;
- int headIdx;
- int tailIdx;
- int size;
- int capacity;
-
- public QueueInt(int capacity) {
- this.capacity = capacity;
- data = new int[capacity];
- }
-
- public final int get() {
-
- if (size == 0) {
- throw new ArrayIndexOutOfBoundsException(Messages.QueueInt_ZeroSizeQueue.pattern);
- }
- int result = data[headIdx];
- headIdx++;
- size--;
-
- if (headIdx == capacity) headIdx = 0;
-
- return result;
- }
-
- public final int size() {
- return size;
- }
-
- public final void put(int x) {
-
- if (tailIdx == capacity) tailIdx = 0;
-
- if (size == capacity) {
- // resize
- capacity <<= 1;
- int[] tmp = new int[capacity];
- int headToEnd = data.length - headIdx;
- System.arraycopy(data, headIdx, tmp, 0, headToEnd);
- if (tailIdx > 0) System.arraycopy(data, 0, tmp, headToEnd, tailIdx);
-
- headIdx = 0;
- tailIdx = data.length;
-
- data = tmp;
- }
-
- data[tailIdx] = x;
- size++;
- tailIdx++;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/collect/SetInt.java b/src/main/java/org/eclipse/mat/collect/SetInt.java
deleted file mode 100644
index ed7086d..0000000
--- a/src/main/java/org/eclipse/mat/collect/SetInt.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.collect;
-
-import java.io.Serializable;
-import java.util.NoSuchElementException;
-
-public final class SetInt implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private int capacity;
- private int step;
- private int limit;
- private int size;
- private boolean[] used;
- private int[] keys;
-
- public SetInt() {
- this(10);
- }
-
- public SetInt(int initialCapacity) {
- init(initialCapacity);
- }
-
- public boolean add(int key) {
- if (size == limit) {
- resize(capacity << 1);
- }
- int hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- return false;
- }
- hash = (hash + step) % capacity;
- }
- used[hash] = true;
- keys[hash] = key;
- size++;
- return true;
- }
-
- public boolean remove(int key) {
- int hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- used[hash] = false;
- size--;
- // Re-hash all follow-up entries anew; Do not fiddle with the
- // capacity limit (75 %) otherwise this code may loop forever
- hash = (hash + step) % capacity;
- while (used[hash]) {
- key = keys[hash];
- used[hash] = false;
- int newHash = (key & Integer.MAX_VALUE) % capacity;
- while (used[newHash]) {
- newHash = (newHash + step) % capacity;
- }
- used[newHash] = true;
- keys[newHash] = key;
- hash = (hash + step) % capacity;
- }
- return true;
- }
- hash = (hash + step) % capacity;
- }
- return false;
- }
-
- public boolean contains(int key) {
- int hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- if (keys[hash] == key) {
- return true;
- }
- hash = (hash + step) % capacity;
- }
- return false;
- }
-
- public int size() {
- return size;
- }
-
- public boolean isEmpty() {
- return size() == 0;
- }
-
- public void clear() {
- size = 0;
- used = new boolean[capacity];
- }
-
- public IteratorInt iterator() {
- return new IteratorInt() {
- int n = 0;
- int i = -1;
-
- public boolean hasNext() {
- return n < size;
- }
-
- public int next() throws NoSuchElementException {
- while (++i < used.length) {
- if (used[i]) {
- n++;
- return keys[i];
- }
- }
- throw new NoSuchElementException();
- }
- };
- }
-
- public int[] toArray() {
- int[] array = new int[size];
- int j = 0;
- for (int i = 0; i < used.length; i++) {
- if (used[i]) {
- array[j++] = keys[i];
- }
- }
- return array;
- }
-
- private void init(int initialCapacity) {
- capacity = PrimeFinder.findNextPrime(initialCapacity);
- step = Math.max(1, PrimeFinder.findPrevPrime(initialCapacity / 3));
- limit = (int) (capacity * 0.75);
- clear();
- keys = new int[capacity];
- }
-
- private void resize(int newCapacity) {
- int oldSize = size;
- boolean[] oldUsed = used;
- int[] oldKeys = keys;
- init(newCapacity);
- int key, hash;
- for (int i = 0; i < oldUsed.length; i++) {
- if (oldUsed[i]) {
- key = oldKeys[i];
- hash = (key & Integer.MAX_VALUE) % capacity;
- while (used[hash]) {
- hash = (hash + step) % capacity;
- }
- used[hash] = true;
- keys[hash] = key;
- }
- }
- size = oldSize;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/hprof/AbstractParser.java b/src/main/java/org/eclipse/mat/hprof/AbstractParser.java
deleted file mode 100644
index 3ffa9c8..0000000
--- a/src/main/java/org/eclipse/mat/hprof/AbstractParser.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.hprof;
-
-import java.io.IOException;
-import java.io.InputStream;
-import org.eclipse.mat.parser.io.PositionInputStream;
-import org.eclipse.mat.snapshot.ISnapshot;
-import org.eclipse.mat.snapshot.model.IObject;
-import org.eclipse.mat.snapshot.model.IPrimitiveArray;
-import org.eclipse.mat.snapshot.model.ObjectReference;
-import org.eclipse.mat.util.MessageUtil;
-
-/*
- * Hprof binary format as defined here:
- * http://hg.openjdk.java.net/jdk7/jdk7/jdk/raw-file/tip/src/share/demo/jvmti/hprof/manual.html
- *
- * Android extensions defined here:
- * http://android.git.kernel.org/?p=platform/dalvik.git;a=blob;f=tools/hprof-conv/HprofConv.c
- */
-
-/* package */abstract class AbstractParser {
- /* package */enum Version {
- JDK12BETA3("JAVA PROFILE 1.0"), //$NON-NLS-1$
- JDK12BETA4("JAVA PROFILE 1.0.1"), //$NON-NLS-1$
- JDK6("JAVA PROFILE 1.0.2"), //$NON-NLS-1$
- ANDROID103("JAVA PROFILE 1.0.3"); //$NON-NLS-1$
-
- private String label;
-
- private Version(String label) {
- this.label = label;
- }
-
- public static Version byLabel(String label) {
- for (Version v : Version.values()) {
- if (v.label.equals(label)) return v;
- }
- return null;
- }
-
- public String getLabel() {
- return label;
- }
- }
-
- interface Constants {
- interface Record {
- int STRING_IN_UTF8 = 0x01;
- int LOAD_CLASS = 0x02;
- int UNLOAD_CLASS = 0x03;
- int STACK_FRAME = 0x04;
- int STACK_TRACE = 0x05;
- int ALLOC_SITES = 0x06;
- int HEAP_SUMMARY = 0x07;
- int START_THREAD = 0x0a;
- int END_THREAD = 0x0b;
- int HEAP_DUMP = 0x0c;
- int HEAP_DUMP_SEGMENT = 0x1c;
- int HEAP_DUMP_END = 0x2c;
- int CPU_SAMPLES = 0x0d;
- int CONTROL_SETTINGS = 0x0e;
- }
-
- interface DumpSegment {
- int ROOT_UNKNOWN = 0xff;
- int ROOT_JNI_GLOBAL = 0x01;
- int ROOT_JNI_LOCAL = 0x02;
- int ROOT_JAVA_FRAME = 0x03;
- int ROOT_NATIVE_STACK = 0x04;
- int ROOT_STICKY_CLASS = 0x05;
- int ROOT_THREAD_BLOCK = 0x06;
- int ROOT_MONITOR_USED = 0x07;
- int ROOT_THREAD_OBJECT = 0x08;
- int CLASS_DUMP = 0x20;
- int INSTANCE_DUMP = 0x21;
- int OBJECT_ARRAY_DUMP = 0x22;
- int PRIMITIVE_ARRAY_DUMP = 0x23;
-
- /* Android 1.0.3 tags */ int ANDROID_HEAP_DUMP_INFO = 0xfe;
- int ANDROID_ROOT_INTERNED_STRING = 0x89;
- int ANDROID_ROOT_FINALIZING = 0x8a;
- int ANDROID_ROOT_DEBUGGER = 0x8b;
- int ANDROID_ROOT_REFERENCE_CLEANUP = 0x8c;
- int ANDROID_ROOT_VM_INTERNAL = 0x8d;
- int ANDROID_ROOT_JNI_MONITOR = 0x8e;
- int ANDROID_UNREACHABLE = 0x90; /* deprecated */
- int ANDROID_PRIMITIVE_ARRAY_NODATA_DUMP = 0xc3;
- }
- }
-
- protected PositionInputStream in;
- protected Version version;
- protected int idSize;
-
- /* package */AbstractParser() {
- }
-
- /* protected */
- static Version readVersion(InputStream in) throws IOException {
- StringBuilder version = new StringBuilder();
-
- int bytesRead = 0;
- while (bytesRead < 20) {
- byte b = (byte) in.read();
- bytesRead++;
-
- if (b != 0) {
- version.append((char) b);
- } else {
- Version answer = Version.byLabel(version.toString());
- if (answer == null) {
- if (bytesRead <= 13) // did not read "JAVA PROFILE "
- {
- throw new IOException(Messages.AbstractParser_Error_NotHeapDump.pattern);
- } else {
- throw new IOException(
- MessageUtil.format(Messages.AbstractParser_Error_UnknownHPROFVersion,
- version.toString()));
- }
- }
-
- if (answer == Version.JDK12BETA3) // not supported by MAT
- {
- throw new IOException(
- MessageUtil.format(Messages.AbstractParser_Error_UnsupportedHPROFVersion,
- answer.getLabel()));
- }
- return answer;
- }
- }
-
- throw new IOException(Messages.AbstractParser_Error_InvalidHPROFHeader.pattern);
- }
-
- protected long readUnsignedInt() throws IOException {
- return (0x0FFFFFFFFL & in.readInt());
- }
-
- protected long readID() throws IOException {
- return idSize == 4 ? (0x0FFFFFFFFL & in.readInt()) : in.readLong();
- }
-
- protected Object readValue(ISnapshot snapshot) throws IOException {
- byte type = in.readByte();
- return readValue(snapshot, type);
- }
-
- protected Object readValue(ISnapshot snapshot, int type) throws IOException {
- switch (type) {
- case IObject.Type.OBJECT:
- long id = readID();
- return id == 0 ? null : new ObjectReference(snapshot, id);
- case IObject.Type.BOOLEAN:
- return in.readByte() != 0;
- case IObject.Type.CHAR:
- return in.readChar();
- case IObject.Type.FLOAT:
- return in.readFloat();
- case IObject.Type.DOUBLE:
- return in.readDouble();
- case IObject.Type.BYTE:
- return in.readByte();
- case IObject.Type.SHORT:
- return in.readShort();
- case IObject.Type.INT:
- return in.readInt();
- case IObject.Type.LONG:
- return in.readLong();
- default:
- throw new IOException(MessageUtil.format(Messages.AbstractParser_Error_IllegalType, type));
- }
- }
-
- protected void skipValue() throws IOException {
- byte type = in.readByte();
- skipValue(type);
- }
-
- protected void skipValue(int type) throws IOException {
- if (type == 2) {
- in.skipBytes(idSize);
- } else {
- in.skipBytes(IPrimitiveArray.ELEMENT_SIZE[type]);
- }
- }
-
- /**
- * Usually the HPROF file contains exactly one heap dump. However, when
- * acquiring heap dumps via the legacy HPROF agent, the dump file can
- * possibly contain multiple heap dumps. Currently there is no API and no UI
- * to determine which dump to use. As this happens very rarely, we decided
- * to go with the following mechanism: use only the first dump unless the
- * user provides a dump number via environment variable. Once the dump has
- * been parsed, the same dump is reopened regardless of the environment
- * variable.
- */
- protected int determineDumpNumber() {
- String dumpNr = System.getProperty("MAT_HPROF_DUMP_NR"); //$NON-NLS-1$
- return dumpNr == null ? 0 : Integer.parseInt(dumpNr);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/hprof/ArrayDescription.java b/src/main/java/org/eclipse/mat/hprof/ArrayDescription.java
deleted file mode 100644
index fcd2d4f..0000000
--- a/src/main/java/org/eclipse/mat/hprof/ArrayDescription.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.hprof;
-
-import java.lang.ref.SoftReference;
-
-/* package */class ArrayDescription {
- /* package */static class Offline extends ArrayDescription {
- boolean isPrimitive;
- long position;
- int arraySize;
- int elementSize;
-
- SoftReference<Object> lazyReadContent = new SoftReference<Object>(null);
-
- public Offline(boolean isPrimitive, long position, int elementSize, int arraySize) {
- this.isPrimitive = isPrimitive;
- this.position = position;
- this.elementSize = elementSize;
- this.arraySize = arraySize;
- }
-
- public boolean isPrimitive() {
- return isPrimitive;
- }
-
- public long getPosition() {
- return position;
- }
-
- public int getArraySize() {
- return arraySize;
- }
-
- public int getElementSize() {
- return elementSize;
- }
-
- public Object getLazyReadContent() {
- return lazyReadContent.get();
- }
-
- public void setLazyReadContent(Object content) {
- this.lazyReadContent = new SoftReference<Object>(content);
- }
- }
-
- /* package */static class Raw extends ArrayDescription {
- byte[] content;
-
- public Raw(byte[] content) {
- this.content = content;
- }
-
- public byte[] getContent() {
- return content;
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/hprof/HprofHeapObjectReader.java b/src/main/java/org/eclipse/mat/hprof/HprofHeapObjectReader.java
deleted file mode 100644
index 87835c8..0000000
--- a/src/main/java/org/eclipse/mat/hprof/HprofHeapObjectReader.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.hprof;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.hprof.extension.IRuntimeEnhancer;
-import org.eclipse.mat.parser.IObjectReader;
-import org.eclipse.mat.parser.index.IIndexReader;
-import org.eclipse.mat.parser.index.IndexReader;
-import org.eclipse.mat.parser.model.AbstractArrayImpl;
-import org.eclipse.mat.parser.model.ObjectArrayImpl;
-import org.eclipse.mat.parser.model.PrimitiveArrayImpl;
-import org.eclipse.mat.snapshot.ISnapshot;
-import org.eclipse.mat.snapshot.model.IObject;
-import org.eclipse.mat.snapshot.model.IPrimitiveArray;
-
-public class HprofHeapObjectReader implements IObjectReader {
- public static final String VERSION_PROPERTY = "hprof.version"; //$NON-NLS-1$
-
- private ISnapshot snapshot;
- private HprofRandomAccessParser hprofDump;
- private IIndexReader.IOne2LongIndex o2hprof;
- private List<IRuntimeEnhancer> enhancers;
-
- public void open(ISnapshot snapshot) throws IOException {
- this.snapshot = snapshot;
-
- AbstractParser.Version version = AbstractParser.Version.valueOf(
- (String) snapshot.getSnapshotInfo().getProperty(VERSION_PROPERTY));
-
- this.hprofDump = new HprofRandomAccessParser(new File(snapshot.getSnapshotInfo().getPath()), //
- version, //
- snapshot.getSnapshotInfo().getIdentifierSize());
- this.o2hprof = new IndexReader.LongIndexReader(
- new File(snapshot.getSnapshotInfo().getPrefix() + "o2hprof.index")); //$NON-NLS-1$
-
- this.enhancers = new ArrayList<IRuntimeEnhancer>();
- // There is no ehancers so far.
- // for (EnhancerRegistry.Enhancer enhancer : EnhancerRegistry.instance().delegates())
- // {
- // IRuntimeEnhancer runtime = enhancer.runtime();
- // if (runtime != null)
- // this.enhancers.add(runtime);
- // }
- }
-
- public long[] readObjectArrayContent(ObjectArrayImpl array, int offset, int length)
- throws IOException, SnapshotException {
- Object info = array.getInfo();
-
- if (info instanceof ArrayDescription.Offline) {
- ArrayDescription.Offline description = (ArrayDescription.Offline) info;
-
- long[] answer = (long[]) description.getLazyReadContent();
- if (answer == null) {
- answer = hprofDump.readObjectArray(description, offset, length);
-
- // save content if fully read...
- if (offset == 0 && length == array.getLength()) description.setLazyReadContent(answer);
-
- return answer;
- } else {
- return (long[]) fragment(array, answer, offset, length);
- }
- } else if (info instanceof long[]) {
- return (long[]) fragment(array, info, offset, length);
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- public Object readPrimitiveArrayContent(PrimitiveArrayImpl array, int offset, int length)
- throws IOException, SnapshotException {
- Object info = array.getInfo();
-
- if (info instanceof ArrayDescription.Offline) {
- ArrayDescription.Offline description = (ArrayDescription.Offline) info;
-
- Object content = description.getLazyReadContent();
- if (content == null) {
- content = convert(array, hprofDump.readPrimitiveArray(description, offset, length));
-
- // save content if fully read...
- if (offset == 0 && length == array.getLength()) description.setLazyReadContent(content);
-
- return content;
- } else {
- return fragment(array, content, offset, length);
- }
- } else if (info instanceof ArrayDescription.Raw) {
- ArrayDescription.Raw description = (ArrayDescription.Raw) info;
- Object content = convert(array, description.getContent());
- array.setInfo(content);
-
- return fragment(array, content, offset, length);
- } else {
- return fragment(array, info, offset, length);
- }
- }
-
- private Object convert(PrimitiveArrayImpl array, byte[] content) {
- if (array.getType() == IObject.Type.BYTE) return content;
-
- int elementSize = IPrimitiveArray.ELEMENT_SIZE[array.getType()];
- int length = content.length / elementSize;
-
- Object answer = Array.newInstance(IPrimitiveArray.COMPONENT_TYPE[array.getType()], length);
-
- int index = 0;
- for (int ii = 0; ii < content.length; ii += elementSize) {
- switch (array.getType()) {
- case IObject.Type.BOOLEAN:
- Array.set(answer, index, content[ii] != 0);
- break;
- case IObject.Type.CHAR:
- Array.set(answer, index, readChar(content, ii));
- break;
- case IObject.Type.FLOAT:
- Array.set(answer, index, readFloat(content, ii));
- break;
- case IObject.Type.DOUBLE:
- Array.set(answer, index, readDouble(content, ii));
- break;
- case IObject.Type.SHORT:
- Array.set(answer, index, readShort(content, ii));
- break;
- case IObject.Type.INT:
- Array.set(answer, index, readInt(content, ii));
- break;
- case IObject.Type.LONG:
- Array.set(answer, index, readLong(content, ii));
- break;
- }
-
- index++;
- }
-
- return answer;
- }
-
- private Object fragment(AbstractArrayImpl array, Object content, int offset, int length) {
- if (offset == 0 && length == array.getLength()) return content;
-
- Object answer = Array.newInstance(content.getClass().getComponentType(), length);
- System.arraycopy(content, offset, answer, 0, length);
- return answer;
- }
-
- public IObject read(int objectId, ISnapshot snapshot) throws SnapshotException, IOException {
- long filePosition = o2hprof.get(objectId);
- return hprofDump.read(objectId, filePosition, snapshot);
- }
-
- public <A> A getAddon(Class<A> addon) throws SnapshotException {
- for (IRuntimeEnhancer enhancer : enhancers) {
- A answer = enhancer.getAddon(snapshot, addon);
- if (answer != null) return answer;
- }
- return null;
- }
-
- public void close() throws IOException {
- try {
- hprofDump.close();
- } catch (IOException ignore) {
- }
-
- try {
- o2hprof.close();
- } catch (IOException ignore) {
- }
- }
-
- // //////////////////////////////////////////////////////////////
- // conversion routines
- // //////////////////////////////////////////////////////////////
-
- private short readShort(byte[] data, int offset) {
- int b1 = (data[offset] & 0xff);
- int b2 = (data[offset + 1] & 0xff);
- return (short) ((b1 << 8) + b2);
- }
-
- private char readChar(byte[] data, int offset) {
- int b1 = (data[offset] & 0xff);
- int b2 = (data[offset + 1] & 0xff);
- return (char) ((b1 << 8) + b2);
- }
-
- private int readInt(byte[] data, int offset) {
- int ch1 = data[offset] & 0xff;
- int ch2 = data[offset + 1] & 0xff;
- int ch3 = data[offset + 2] & 0xff;
- int ch4 = data[offset + 3] & 0xff;
- return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
- }
-
- private float readFloat(byte[] data, int offset) {
- return Float.intBitsToFloat(readInt(data, offset));
- }
-
- private long readLong(byte[] data, int offset) {
- return ((((long) data[offset] & 0xff) << 56) + //
- ((long) (data[offset + 1] & 0xff) << 48) + //
- ((long) (data[offset + 2] & 0xff) << 40) + //
- ((long) (data[offset + 3] & 0xff) << 32) + //
- ((long) (data[offset + 4] & 0xff) << 24) + //
- ((data[offset + 5] & 0xff) << 16) + //
- ((data[offset + 6] & 0xff) << 8) + //
- ((data[offset + 7] & 0xff) << 0));
- }
-
- private double readDouble(byte[] data, int offset) {
- return Double.longBitsToDouble(readLong(data, offset));
- }
-}
diff --git a/src/main/java/org/eclipse/mat/hprof/HprofIndexBuilder.java b/src/main/java/org/eclipse/mat/hprof/HprofIndexBuilder.java
deleted file mode 100644
index 3f06170..0000000
--- a/src/main/java/org/eclipse/mat/hprof/HprofIndexBuilder.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.hprof;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.IteratorLong;
-import org.eclipse.mat.hprof.extension.IParsingEnhancer;
-import org.eclipse.mat.parser.IIndexBuilder;
-import org.eclipse.mat.parser.IPreliminaryIndex;
-import org.eclipse.mat.parser.index.IIndexReader.IOne2LongIndex;
-import org.eclipse.mat.parser.index.IndexWriter;
-import org.eclipse.mat.util.IProgressListener;
-import org.eclipse.mat.util.MessageUtil;
-import org.eclipse.mat.util.SimpleMonitor;
-
-public class HprofIndexBuilder implements IIndexBuilder {
- private File file;
- private String prefix;
- private IOne2LongIndex id2position;
- private List<IParsingEnhancer> enhancers;
-
- public void init(File file, String prefix) {
- this.file = file;
- this.prefix = prefix;
-
- this.enhancers = new ArrayList<IParsingEnhancer>();
- // there is no enhancers so far.
- // for (EnhancerRegistry.Enhancer enhancer : EnhancerRegistry.instance().delegates())
- // {
- // IParsingEnhancer parsingEnhancer = enhancer.parser();
- // if (parsingEnhancer != null)
- // this.enhancers.add(parsingEnhancer);
- // }
-
- }
-
- public void fill(IPreliminaryIndex preliminary, IProgressListener listener)
- throws SnapshotException, IOException {
- SimpleMonitor monitor = new SimpleMonitor(MessageUtil.format(Messages.HprofIndexBuilder_Parsing,
- new Object[] { file.getAbsolutePath() }), listener, new int[] { 500, 1500 });
-
- listener.beginTask(MessageUtil.format(Messages.HprofIndexBuilder_Parsing, file.getName()),
- 3000);
-
- IHprofParserHandler handler = new HprofParserHandlerImpl();
- handler.beforePass1(preliminary.getSnapshotInfo());
-
- SimpleMonitor.Listener mon = (SimpleMonitor.Listener) monitor.nextMonitor();
- mon.beginTask(MessageUtil.format(Messages.HprofIndexBuilder_Scanning,
- new Object[] { file.getAbsolutePath() }), (int) (file.length() / 1000));
- Pass1Parser pass1 = new Pass1Parser(handler, mon);
- pass1.read(file);
-
- if (listener.isCanceled()) throw new IProgressListener.OperationCanceledException();
-
- mon.done();
-
- handler.beforePass2(listener);
-
- mon = (SimpleMonitor.Listener) monitor.nextMonitor();
- mon.beginTask(MessageUtil.format(Messages.HprofIndexBuilder_ExtractingObjects, new Object[] {
- file.getAbsolutePath()
- }), (int) (file.length() / 1000));
-
- Pass2Parser pass2 = new Pass2Parser(handler, mon);
- pass2.read(file);
-
- if (listener.isCanceled()) throw new IProgressListener.OperationCanceledException();
-
- mon.done();
-
- if (listener.isCanceled()) throw new IProgressListener.OperationCanceledException();
-
- for (IParsingEnhancer enhancer : enhancers)
- enhancer.onParsingCompleted(handler.getSnapshotInfo());
-
- id2position = handler.fillIn(preliminary);
- }
-
- public void clean(final int[] purgedMapping, IProgressListener listener) throws IOException {
-
- // //////////////////////////////////////////////////////////////
- // object 2 hprof position
- // //////////////////////////////////////////////////////////////
-
- File indexFile = new File(prefix + "o2hprof.index"); //$NON-NLS-1$
- listener.subTask(MessageUtil.format(Messages.HprofIndexBuilder_Writing, new Object[] {
- indexFile.getAbsolutePath()
- }));
- IOne2LongIndex newIndex = new IndexWriter.LongIndexStreamer().writeTo(indexFile,
- new IndexIterator(id2position, purgedMapping));
-
- try {
- newIndex.close();
- } catch (IOException ignore) {
- }
-
- try {
- id2position.close();
- } catch (IOException ignore) {
- }
-
- id2position.delete();
- id2position = null;
- }
-
- public void cancel() {
- if (id2position != null) {
- try {
- id2position.close();
- } catch (IOException ignore) {
- // $JL-EXC$
- }
- id2position.delete();
- }
- }
-
- private static final class IndexIterator implements IteratorLong {
- private final IOne2LongIndex id2position;
- private final int[] purgedMapping;
- private int nextIndex = -1;
-
- private IndexIterator(IOne2LongIndex id2position, int[] purgedMapping) {
- this.id2position = id2position;
- this.purgedMapping = purgedMapping;
- findNext();
- }
-
- public boolean hasNext() {
- return nextIndex < purgedMapping.length;
- }
-
- public long next() {
- long answer = id2position.get(nextIndex);
- findNext();
- return answer;
- }
-
- protected void findNext() {
- nextIndex++;
- while (nextIndex < purgedMapping.length && purgedMapping[nextIndex] < 0) nextIndex++;
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/hprof/HprofParserHandlerImpl.java b/src/main/java/org/eclipse/mat/hprof/HprofParserHandlerImpl.java
deleted file mode 100644
index 5c90349..0000000
--- a/src/main/java/org/eclipse/mat/hprof/HprofParserHandlerImpl.java
+++ /dev/null
@@ -1,470 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.hprof;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.HashMapIntObject;
-import org.eclipse.mat.collect.HashMapLongObject;
-import org.eclipse.mat.collect.IteratorLong;
-import org.eclipse.mat.parser.IPreliminaryIndex;
-import org.eclipse.mat.parser.index.IIndexReader.IOne2LongIndex;
-import org.eclipse.mat.parser.index.IndexManager.Index;
-import org.eclipse.mat.parser.index.IndexWriter;
-import org.eclipse.mat.parser.model.ClassImpl;
-import org.eclipse.mat.parser.model.XGCRootInfo;
-import org.eclipse.mat.parser.model.XSnapshotInfo;
-import org.eclipse.mat.snapshot.model.Field;
-import org.eclipse.mat.snapshot.model.FieldDescriptor;
-import org.eclipse.mat.snapshot.model.GCRootInfo;
-import org.eclipse.mat.snapshot.model.IClass;
-import org.eclipse.mat.snapshot.model.IPrimitiveArray;
-import org.eclipse.mat.util.IProgressListener;
-import org.eclipse.mat.util.MessageUtil;
-
-public class HprofParserHandlerImpl implements IHprofParserHandler {
- // private String prefix;
- private AbstractParser.Version version;
-
- private XSnapshotInfo info = new XSnapshotInfo();
-
- /** constant pool cache */
- private HashMapLongObject<String> constantPool = new HashMapLongObject<String>(10000);
- private Map<String, List<ClassImpl>> classesByName = new HashMap<String, List<ClassImpl>>();
- private HashMapLongObject<ClassImpl> classesByAddress = new HashMapLongObject<ClassImpl>();
-
- private HashMapLongObject<List<XGCRootInfo>> gcRoots =
- new HashMapLongObject<List<XGCRootInfo>>(200);
-
- private IndexWriter.Identifier identifiers = null;
- private IndexWriter.IntArray1NWriter outbound = null;
- private IndexWriter.IntIndexCollector object2classId = null;
- private IndexWriter.LongIndexCollector object2position = null;
- private IndexWriter.IntIndexCollectorUncompressed array2size = null;
-
- private Set<Long> requiredArrayClassIDs = new HashSet<Long>();
- private Set<Integer> requiredPrimitiveArrays = new HashSet<Integer>();
-
- private HashMapLongObject<HashMapLongObject<List<XGCRootInfo>>> threadAddressToLocals =
- new HashMapLongObject<HashMapLongObject<List<XGCRootInfo>>>();
-
- // //////////////////////////////////////////////////////////////
- // lifecycle
- // //////////////////////////////////////////////////////////////
-
- public void beforePass1(XSnapshotInfo snapshotInfo) throws IOException {
- this.info = snapshotInfo;
- this.identifiers = new IndexWriter.Identifier();
- }
-
- public void beforePass2(IProgressListener monitor) throws IOException, SnapshotException {
- // add dummy address for system class loader object
- identifiers.add(0);
-
- // sort and assign preliminary object ids
- identifiers.sort();
-
- // if necessary, create required classes not contained in the heap
- if (!requiredArrayClassIDs.isEmpty() || !requiredPrimitiveArrays.isEmpty()) {
- createRequiredFakeClasses();
- }
-
- // informational messages to the user
- monitor.sendUserMessage(IProgressListener.Severity.INFO,
- MessageUtil.format(Messages.HprofParserHandlerImpl_HeapContainsObjects, info.getPath(),
- identifiers.size()), null);
-
- int maxClassId = 0;
-
- // calculate instance size for all classes
- for (Iterator<?> e = classesByAddress.values(); e.hasNext(); ) {
- ClassImpl clazz = (ClassImpl) e.next();
- int index = identifiers.reverse(clazz.getObjectAddress());
- clazz.setObjectId(index);
-
- maxClassId = Math.max(maxClassId, index);
-
- clazz.setHeapSizePerInstance(calculateInstanceSize(clazz));
- clazz.setUsedHeapSize(calculateClassSize(clazz));
- }
-
- // create index writers
- outbound = new IndexWriter.IntArray1NWriter(this.identifiers.size(),
- Index.OUTBOUND.getFile(info.getPrefix() + "temp."));//$NON-NLS-1$
- object2classId = new IndexWriter.IntIndexCollector(this.identifiers.size(),
- IndexWriter.mostSignificantBit(maxClassId));
- object2position = new IndexWriter.LongIndexCollector(this.identifiers.size(),
- IndexWriter.mostSignificantBit(new File(this.info.getPath()).length()));
- array2size = new IndexWriter.IntIndexCollectorUncompressed(this.identifiers.size());
-
- // java.lang.Class needs some special treatment so that object2classId
- // is written correctly
- List<ClassImpl> javaLangClasses = classesByName.get(ClassImpl.JAVA_LANG_CLASS);
- ClassImpl javaLangClass = javaLangClasses.get(0);
- javaLangClass.setObjectId(identifiers.reverse(javaLangClass.getObjectAddress()));
-
- // log references for classes
- for (Iterator<?> e = classesByAddress.values(); e.hasNext(); ) {
- ClassImpl clazz = (ClassImpl) e.next();
- clazz.setSuperClassIndex(identifiers.reverse(clazz.getSuperClassAddress()));
- clazz.setClassLoaderIndex(identifiers.reverse(clazz.getClassLoaderAddress()));
-
- // [INFO] in newer jdk hprof files, the boot class loader
- // has an address other than 0. The class loader instances
- // is still not contained in the hprof file
- if (clazz.getClassLoaderId() < 0) {
- clazz.setClassLoaderAddress(0);
- clazz.setClassLoaderIndex(identifiers.reverse(0));
- }
-
- // add class instance
- clazz.setClassInstance(javaLangClass);
- javaLangClass.addInstance(clazz.getUsedHeapSize());
-
- // resolve super class
- ClassImpl superclass = lookupClass(clazz.getSuperClassAddress());
- if (superclass != null) superclass.addSubClass(clazz);
-
- object2classId.set(clazz.getObjectId(), clazz.getClazz().getObjectId());
-
- outbound.log(identifiers, clazz.getObjectId(), clazz.getReferences());
- }
-
- // report dependencies for system class loader
- // (if no classes use this class loader, cleanup garbage will remove it
- // again)
- ClassImpl classLoaderClass = this.classesByName.get(IClass.JAVA_LANG_CLASSLOADER).get(0);
- HeapObject heapObject = new HeapObject(this.identifiers.reverse(0), 0, classLoaderClass,
- classLoaderClass.getHeapSizePerInstance());
- heapObject.references.add(classLoaderClass.getObjectAddress());
- this.addObject(heapObject, 0);
-
- constantPool = null;
- }
-
- private void createRequiredFakeClasses() throws IOException, SnapshotException {
- // we know: system class loader has object address 0
- long nextObjectAddress = 0;
-
- // create required (fake) classes for arrays
- if (!requiredArrayClassIDs.isEmpty()) {
- for (long arrayClassID : requiredArrayClassIDs) {
- IClass arrayType = lookupClass(arrayClassID);
- if (arrayType == null) {
- int objectId = identifiers.reverse(arrayClassID);
- if (objectId >= 0) {
- String msg =
- MessageUtil.format(Messages.HprofParserHandlerImpl_Error_ExpectedClassSegment,
- Long.toHexString(arrayClassID));
- throw new SnapshotException(msg);
- }
-
- arrayType =
- new ClassImpl(arrayClassID, "unknown-class[]", 0, 0, new Field[0], //$NON-NLS-1$
- new FieldDescriptor[0]);
- addClass((ClassImpl) arrayType, -1);
- }
- }
- }
- requiredArrayClassIDs = null;
-
- if (!requiredPrimitiveArrays.isEmpty()) {
- for (Integer arrayType : requiredPrimitiveArrays) {
- String name = IPrimitiveArray.TYPE[arrayType];
- IClass clazz = lookupClassByName(name, true);
- if (clazz == null) {
- while (identifiers.reverse(++nextObjectAddress) >= 0) {
- }
-
- clazz =
- new ClassImpl(nextObjectAddress, name, 0, 0, new Field[0], new FieldDescriptor[0]);
- addClass((ClassImpl) clazz, -1);
- }
- }
- }
-
- identifiers.sort();
- }
-
- private int calculateInstanceSize(ClassImpl clazz) {
- if (!clazz.isArrayType()) {
- return alignUpToX(calculateSizeRecursive(clazz), 8);
- } else {
- // use the instanceSize only to pass the proper ID size
- // arrays calculate the rest themselves.
- return info.getIdentifierSize();
- }
- }
-
- private int calculateSizeRecursive(ClassImpl clazz) {
- if (clazz.getSuperClassAddress() == 0) {
- return 2 * info.getIdentifierSize();
- }
- ClassImpl superClass = classesByAddress.get(clazz.getSuperClassAddress());
- int ownFieldsSize = 0;
- for (FieldDescriptor field : clazz.getFieldDescriptors())
- ownFieldsSize += sizeOf(field);
-
- return alignUpToX(ownFieldsSize + calculateSizeRecursive(superClass), info.getIdentifierSize());
- }
-
- private int calculateClassSize(ClassImpl clazz) {
- int staticFieldsSize = 0;
- for (Field field : clazz.getStaticFields())
- staticFieldsSize += sizeOf(field);
- return alignUpToX(staticFieldsSize, 8);
- }
-
- private int sizeOf(FieldDescriptor field) {
- int type = field.getType();
- if (type == 2) return info.getIdentifierSize();
-
- return IPrimitiveArray.ELEMENT_SIZE[type];
- }
-
- private int alignUpToX(int n, int x) {
- int r = n % x;
- return r == 0 ? n : n + x - r;
- }
-
- public IOne2LongIndex fillIn(IPreliminaryIndex index) throws IOException {
- // ensure all classes loaded by the system class loaders are marked as
- // GCRoots
- //
- // For some dumps produced with jmap 1.5_xx this is not the case, and
- // it may happen that the super classes of some classes are missing
- // Array classes, e.g. java.lang.String[][] are not explicitly
- // marked. They are also not marked as "system class" in the non-jmap
- // heap dumps
- ClassImpl[] allClasses = classesByAddress.getAllValues(new ClassImpl[0]);
- for (ClassImpl clazz : allClasses) {
- if (clazz.getClassLoaderAddress() == 0 && !clazz.isArrayType() && !gcRoots.containsKey(
- clazz.getObjectAddress())) {
- addGCRoot(clazz.getObjectAddress(), 0, GCRootInfo.Type.SYSTEM_CLASS);
- }
- }
-
- // classes model
- HashMapIntObject<ClassImpl> classesById =
- new HashMapIntObject<ClassImpl>(classesByAddress.size());
- for (Iterator<ClassImpl> iter = classesByAddress.values(); iter.hasNext(); ) {
- ClassImpl clazz = iter.next();
- classesById.put(clazz.getObjectId(), clazz);
- }
- index.setClassesById(classesById);
-
- index.setGcRoots(map2ids(gcRoots));
-
- HashMapIntObject<HashMapIntObject<List<XGCRootInfo>>> thread2objects2roots =
- new HashMapIntObject<HashMapIntObject<List<XGCRootInfo>>>();
- for (Iterator<HashMapLongObject.Entry<HashMapLongObject<List<XGCRootInfo>>>> iter =
- threadAddressToLocals.entries(); iter.hasNext(); ) {
- HashMapLongObject.Entry<HashMapLongObject<List<XGCRootInfo>>> entry = iter.next();
- int threadId = identifiers.reverse(entry.getKey());
- if (threadId >= 0) {
- HashMapIntObject<List<XGCRootInfo>> objects2roots = map2ids(entry.getValue());
- if (!objects2roots.isEmpty()) thread2objects2roots.put(threadId, objects2roots);
- }
- }
- index.setThread2objects2roots(thread2objects2roots);
-
- index.setIdentifiers(identifiers);
-
- index.setArray2size(
- array2size.writeTo(Index.A2SIZE.getFile(info.getPrefix() + "temp."))); //$NON-NLS-1$
-
- index.setObject2classId(object2classId);
-
- index.setOutbound(outbound.flush());
-
- return object2position.writeTo(new File(info.getPrefix() + "temp.o2hprof.index")); //$NON-NLS-1$
- }
-
- private HashMapIntObject<List<XGCRootInfo>> map2ids(HashMapLongObject<List<XGCRootInfo>> source) {
- HashMapIntObject<List<XGCRootInfo>> sink = new HashMapIntObject<List<XGCRootInfo>>();
- for (Iterator<HashMapLongObject.Entry<List<XGCRootInfo>>> iter = source.entries();
- iter.hasNext(); ) {
- HashMapLongObject.Entry<List<XGCRootInfo>> entry = iter.next();
- int idx = identifiers.reverse(entry.getKey());
- if (idx >= 0) {
- // sometimes it happens that there is no object for an
- // address reported as a GC root. It's not clear why
- for (Iterator<XGCRootInfo> roots = entry.getValue().iterator(); roots.hasNext(); ) {
- XGCRootInfo root = roots.next();
- root.setObjectId(idx);
- if (root.getContextAddress() != 0) {
- int contextId = identifiers.reverse(root.getContextAddress());
- if (contextId < 0) {
- roots.remove();
- } else {
- root.setContextId(contextId);
- }
- }
- }
- sink.put(idx, entry.getValue());
- }
- }
- return sink;
- }
-
- public void cancel() {
- if (constantPool != null) constantPool.clear();
-
- if (outbound != null) outbound.cancel();
- }
-
- // //////////////////////////////////////////////////////////////
- // report parsed entities
- // //////////////////////////////////////////////////////////////
-
- public void addProperty(String name, String value) throws IOException {
- if (IHprofParserHandler.VERSION.equals(name)) {
- version = AbstractParser.Version.valueOf(value);
- info.setProperty(HprofHeapObjectReader.VERSION_PROPERTY, version.name());
- } else if (IHprofParserHandler.IDENTIFIER_SIZE.equals(name)) {
- info.setIdentifierSize(Integer.parseInt(value));
- } else if (IHprofParserHandler.CREATION_DATE.equals(name)) {
- info.setCreationDate(new Date(Long.parseLong(value)));
- }
- }
-
- @SuppressWarnings("unchecked") public void addGCRoot(long id, long referrer, int rootType) {
- if (referrer != 0) {
- HashMapLongObject localAddressToRootInfo = threadAddressToLocals.get(referrer);
- if (localAddressToRootInfo == null) {
- localAddressToRootInfo = new HashMapLongObject();
- threadAddressToLocals.put(referrer, localAddressToRootInfo);
- }
- List<XGCRootInfo> gcRootInfo = (List<XGCRootInfo>) localAddressToRootInfo.get(id);
- if (gcRootInfo == null) {
- gcRootInfo = new ArrayList<XGCRootInfo>(1);
- localAddressToRootInfo.put(id, gcRootInfo);
- }
- gcRootInfo.add(new XGCRootInfo(id, referrer, rootType));
- return; // do not add the object as GC root
- }
-
- List<XGCRootInfo> r = gcRoots.get(id);
- if (r == null) gcRoots.put(id, r = new ArrayList<XGCRootInfo>(3));
- r.add(new XGCRootInfo(id, referrer, rootType));
- }
-
- public void addClass(ClassImpl clazz, long filePosition) throws IOException {
- this.identifiers.add(clazz.getObjectAddress());
- this.classesByAddress.put(clazz.getObjectAddress(), clazz);
-
- List<ClassImpl> list = classesByName.get(clazz.getName());
- if (list == null) classesByName.put(clazz.getName(), list = new ArrayList<ClassImpl>());
- list.add(clazz);
- }
-
- public void addObject(HeapObject object, long filePosition) throws IOException {
- int index = object.objectId;
-
- // check if some thread to local variables references have to be added
- HashMapLongObject<List<XGCRootInfo>> localVars =
- threadAddressToLocals.get(object.objectAddress);
- if (localVars != null) {
- IteratorLong e = localVars.keys();
- while (e.hasNext()) {
- object.references.add(e.next());
- }
- }
- // log references
- outbound.log(identifiers, index, object.references);
-
- int classIndex = object.clazz.getObjectId();
- object.clazz.addInstance(object.usedHeapSize);
-
- // log address
- object2classId.set(index, classIndex);
- object2position.set(index, filePosition);
-
- // log array size
- if (object.isArray) array2size.set(index, object.usedHeapSize);
- }
-
- public void reportInstance(long id, long filePosition) {
- this.identifiers.add(id);
- }
-
- public void reportRequiredObjectArray(long arrayClassID) {
- requiredArrayClassIDs.add(arrayClassID);
- }
-
- public void reportRequiredPrimitiveArray(int arrayType) {
- requiredPrimitiveArrays.add(arrayType);
- }
-
- // //////////////////////////////////////////////////////////////
- // lookup heap infos
- // //////////////////////////////////////////////////////////////
-
- public int getIdentifierSize() {
- return info.getIdentifierSize();
- }
-
- public HashMapLongObject<String> getConstantPool() {
- return constantPool;
- }
-
- public ClassImpl lookupClass(long classId) {
- return classesByAddress.get(classId);
- }
-
- public IClass lookupClassByName(String name, boolean failOnMultipleInstances) {
- List<ClassImpl> list = classesByName.get(name);
- if (list == null) return null;
- if (failOnMultipleInstances && list.size() != 1) {
- throw new RuntimeException(
- MessageUtil.format(Messages.HprofParserHandlerImpl_Error_MultipleClassInstancesExist,
- name));
- }
- return list.get(0);
- }
-
- public IClass lookupClassByIndex(int objIndex) {
- return lookupClass(this.identifiers.get(objIndex));
- }
-
- public List<IClass> resolveClassHierarchy(long classId) {
- List<IClass> answer = new ArrayList<IClass>();
-
- ClassImpl clazz = classesByAddress.get(classId);
- answer.add(clazz);
-
- while (clazz.hasSuperClass()) {
- clazz = classesByAddress.get(clazz.getSuperClassAddress());
- answer.add(clazz);
- }
-
- return answer;
- }
-
- public int mapAddressToId(long address) {
- return this.identifiers.reverse(address);
- }
-
- public XSnapshotInfo getSnapshotInfo() {
- return info;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/hprof/HprofRandomAccessParser.java b/src/main/java/org/eclipse/mat/hprof/HprofRandomAccessParser.java
deleted file mode 100644
index 7ce2d76..0000000
--- a/src/main/java/org/eclipse/mat/hprof/HprofRandomAccessParser.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.hprof;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.parser.io.BufferedRandomAccessInputStream;
-import org.eclipse.mat.parser.io.PositionInputStream;
-import org.eclipse.mat.parser.model.ClassImpl;
-import org.eclipse.mat.parser.model.ClassLoaderImpl;
-import org.eclipse.mat.parser.model.InstanceImpl;
-import org.eclipse.mat.parser.model.ObjectArrayImpl;
-import org.eclipse.mat.parser.model.PrimitiveArrayImpl;
-import org.eclipse.mat.snapshot.ISnapshot;
-import org.eclipse.mat.snapshot.model.Field;
-import org.eclipse.mat.snapshot.model.FieldDescriptor;
-import org.eclipse.mat.snapshot.model.IArray;
-import org.eclipse.mat.snapshot.model.IClass;
-import org.eclipse.mat.snapshot.model.IObject;
-import org.eclipse.mat.snapshot.model.IPrimitiveArray;
-import org.eclipse.mat.util.MessageUtil;
-
-public class HprofRandomAccessParser extends AbstractParser {
- public static final int LAZY_LOADING_LIMIT = 256;
-
- public HprofRandomAccessParser(File file, Version version, int identifierSize)
- throws IOException {
- this.in = new PositionInputStream(
- new BufferedRandomAccessInputStream(new RandomAccessFile(file, "r"), 512)); //$NON-NLS-1$
- this.version = version;
- this.idSize = identifierSize;
- }
-
- public synchronized void close() throws IOException {
- in.close();
- }
-
- public synchronized IObject read(int objectId, long position, ISnapshot dump)
- throws IOException, SnapshotException {
- in.seek(position);
- int segmentType = in.readUnsignedByte();
- switch (segmentType) {
- case Constants.DumpSegment.INSTANCE_DUMP:
- return readInstanceDump(objectId, dump);
- case Constants.DumpSegment.OBJECT_ARRAY_DUMP:
- return readObjectArrayDump(objectId, dump);
- case Constants.DumpSegment.PRIMITIVE_ARRAY_DUMP:
- return readPrimitiveArrayDump(objectId, dump);
- default:
- throw new IOException(
- MessageUtil.format(Messages.HprofRandomAccessParser_Error_IllegalDumpSegment,
- segmentType));
- }
- }
-
- public List<IClass> resolveClassHierarchy(ISnapshot snapshot, IClass clazz)
- throws SnapshotException {
- List<IClass> answer = new ArrayList<IClass>();
- answer.add(clazz);
- while (clazz.hasSuperClass()) {
- clazz = (IClass) snapshot.getObject(clazz.getSuperClassId());
- if (clazz == null) return null;
- answer.add(clazz);
- }
-
- return answer;
- }
-
- private IObject readInstanceDump(int objectId, ISnapshot dump)
- throws IOException, SnapshotException {
- long address = readID();
- if (in.skipBytes(8 + idSize) != 8 + idSize) throw new IOException();
-
- // check if we need to defer reading the class
- List<IClass> hierarchy = resolveClassHierarchy(dump, dump.getClassOf(objectId));
- if (hierarchy == null) {
- throw new IOException(Messages.HprofRandomAccessParser_Error_DumpIncomplete.pattern);
- } else {
- List<Field> instanceFields = new ArrayList<Field>();
- for (IClass clazz : hierarchy) {
- List<FieldDescriptor> fields = clazz.getFieldDescriptors();
- for (int ii = 0; ii < fields.size(); ii++) {
- FieldDescriptor field = fields.get(ii);
- int type = field.getType();
- Object value = readValue(dump, type);
- instanceFields.add(new Field(field.getName(), field.getType(), value));
- }
- }
-
- ClassImpl classImpl = (ClassImpl) hierarchy.get(0);
-
- if (dump.isClassLoader(objectId)) {
- return new ClassLoaderImpl(objectId, address, classImpl, instanceFields);
- } else {
- return new InstanceImpl(objectId, address, classImpl, instanceFields);
- }
- }
- }
-
- private IArray readObjectArrayDump(int objectId, ISnapshot dump)
- throws IOException, SnapshotException {
- long id = readID();
-
- in.skipBytes(4);
- int size = in.readInt();
-
- long arrayClassObjectID = readID();
-
- IClass arrayType = (IClass) dump.getObject(dump.mapAddressToId(arrayClassObjectID));
- if (arrayType == null) {
- throw new RuntimeException(Messages.HprofRandomAccessParser_Error_MissingFakeClass.pattern);
- }
-
- Object content = null;
- if (size * idSize < LAZY_LOADING_LIMIT) {
- long[] data = new long[size];
- for (int ii = 0; ii < data.length; ii++)
- data[ii] = readID();
- content = data;
- } else {
- content = new ArrayDescription.Offline(false, in.position(), 0, size);
- }
-
- ObjectArrayImpl array = new ObjectArrayImpl(objectId, id, (ClassImpl) arrayType, size);
- array.setInfo(content);
- return array;
- }
-
- private IArray readPrimitiveArrayDump(int objectId, ISnapshot dump)
- throws IOException, SnapshotException {
- long id = readID();
-
- in.skipBytes(4);
- int arraySize = in.readInt();
-
- long elementType = in.readByte();
- if ((elementType < IPrimitiveArray.Type.BOOLEAN) || (elementType > IPrimitiveArray.Type.LONG)) {
- throw new IOException(Messages.Pass1Parser_Error_IllegalType.pattern);
- }
-
- int elementSize = IPrimitiveArray.ELEMENT_SIZE[(int) elementType];
- int len = elementSize * arraySize;
-
- Object content = null;
- if (len < LAZY_LOADING_LIMIT) {
- byte[] data = new byte[len];
- in.readFully(data);
- content = elementType == IObject.Type.BYTE ? data : new ArrayDescription.Raw(data);
- } else {
- content = new ArrayDescription.Offline(true, in.position(), elementSize, arraySize);
- }
-
- // lookup class by name
- IClass clazz = null;
- String name = IPrimitiveArray.TYPE[(int) elementType];
- Collection<IClass> classes = dump.getClassesByName(name, false);
- if (classes == null || classes.isEmpty()) {
- throw new IOException(
- MessageUtil.format(Messages.HprofRandomAccessParser_Error_MissingClass, name));
- } else if (classes.size() > 1) {
- throw new IOException(
- MessageUtil.format(Messages.HprofRandomAccessParser_Error_DuplicateClass, name));
- } else {
- clazz = classes.iterator().next();
- }
-
- PrimitiveArrayImpl array =
- new PrimitiveArrayImpl(objectId, id, (ClassImpl) clazz, arraySize, (int) elementType);
- array.setInfo(content);
-
- return array;
- }
-
- public synchronized long[] readObjectArray(ArrayDescription.Offline descriptor, int offset,
- int length) throws IOException {
- int elementSize = this.idSize;
-
- in.seek(descriptor.getPosition() + (offset * elementSize));
- long[] data = new long[length];
- for (int ii = 0; ii < data.length; ii++)
- data[ii] = readID();
- return data;
- }
-
- public synchronized byte[] readPrimitiveArray(ArrayDescription.Offline descriptor, int offset,
- int length) throws IOException {
- int elementSize = descriptor.getElementSize();
-
- in.seek(descriptor.getPosition() + (offset * elementSize));
-
- byte[] data = new byte[length * elementSize];
- in.readFully(data);
- return data;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/hprof/IHprofParserHandler.java b/src/main/java/org/eclipse/mat/hprof/IHprofParserHandler.java
deleted file mode 100644
index 7ba4c06..0000000
--- a/src/main/java/org/eclipse/mat/hprof/IHprofParserHandler.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.hprof;
-
-import java.io.IOException;
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.ArrayLong;
-import org.eclipse.mat.collect.HashMapLongObject;
-import org.eclipse.mat.parser.IPreliminaryIndex;
-import org.eclipse.mat.parser.index.IIndexReader.IOne2LongIndex;
-import org.eclipse.mat.parser.model.ClassImpl;
-import org.eclipse.mat.parser.model.XSnapshotInfo;
-import org.eclipse.mat.snapshot.model.IClass;
-import org.eclipse.mat.util.IProgressListener;
-
-public interface IHprofParserHandler {
- String IDENTIFIER_SIZE = "ID_SIZE"; //$NON-NLS-1$
- String CREATION_DATE = "CREATION_DATE"; //$NON-NLS-1$
- String VERSION = "VERSION";//$NON-NLS-1$
-
- public class HeapObject {
- public int objectId;
- public long objectAddress;
- public ClassImpl clazz;
- public int usedHeapSize;
- public ArrayLong references = new ArrayLong();
- public boolean isArray = false;
-
- public HeapObject(int objectId, long objectAddress, ClassImpl clazz, int usedHeapSize) {
- super();
- this.objectId = objectId;
- this.objectAddress = objectAddress;
- this.clazz = clazz;
- this.usedHeapSize = usedHeapSize;
- this.isArray = false;
- }
- }
-
- // //////////////////////////////////////////////////////////////
- // lifecycle
- // //////////////////////////////////////////////////////////////
-
- void beforePass1(XSnapshotInfo snapshotInfo) throws IOException;
-
- void beforePass2(IProgressListener monitor) throws IOException, SnapshotException;
-
- IOne2LongIndex fillIn(IPreliminaryIndex index) throws IOException;
-
- void cancel();
-
- // //////////////////////////////////////////////////////////////
- // report parsed entities
- // //////////////////////////////////////////////////////////////
-
- void addProperty(String name, String value) throws IOException;
-
- void addGCRoot(long id, long referrer, int rootType) throws IOException;
-
- void addClass(ClassImpl clazz, long filePosition) throws IOException;
-
- void addObject(HeapObject object, long filePosition) throws IOException;
-
- void reportInstance(long id, long filePosition);
-
- void reportRequiredObjectArray(long arrayClassID);
-
- void reportRequiredPrimitiveArray(int arrayType);
-
- // //////////////////////////////////////////////////////////////
- // lookup heap infos
- // //////////////////////////////////////////////////////////////
-
- int getIdentifierSize();
-
- HashMapLongObject<String> getConstantPool();
-
- IClass lookupClass(long classId);
-
- IClass lookupClassByName(String name, boolean failOnMultipleInstances);
-
- IClass lookupClassByIndex(int objIndex);
-
- List<IClass> resolveClassHierarchy(long classId);
-
- int mapAddressToId(long address);
-
- XSnapshotInfo getSnapshotInfo();
-}
diff --git a/src/main/java/org/eclipse/mat/hprof/Messages.java b/src/main/java/org/eclipse/mat/hprof/Messages.java
deleted file mode 100644
index 9b68ff1..0000000
--- a/src/main/java/org/eclipse/mat/hprof/Messages.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.eclipse.mat.hprof;
-
-public enum Messages {
-
- AbstractParser_Error_IllegalType("Illegal Type: {0}"),
- AbstractParser_Error_InvalidHPROFHeader("Invalid HPROF file header."),
- AbstractParser_Error_NotHeapDump("Not a HPROF heap dump"),
- AbstractParser_Error_UnknownHPROFVersion("Unknown HPROF Version ({0})"),
- AbstractParser_Error_UnsupportedHPROFVersion("Unsupported HPROF Version {0}"),
- HprofIndexBuilder_ExtractingObjects("Extracting objects from {0}"),
- HprofIndexBuilder_Parsing("Parsing {0}"),
- HprofIndexBuilder_Scanning("Scanning {0}"),
- HprofIndexBuilder_Writing("Writing {0}"),
- HprofParserHandlerImpl_Error_ExpectedClassSegment(
- "Error: Found instance segment but expected class segment (see FAQ): 0x{0}"),
- HprofParserHandlerImpl_Error_MultipleClassInstancesExist(
- "multiple class instances exist for {0}"),
- HprofParserHandlerImpl_HeapContainsObjects("Heap {0} contains {1,number} objects"),
- HprofRandomAccessParser_Error_DumpIncomplete("need to create dummy class. dump incomplete"),
- HprofRandomAccessParser_Error_DuplicateClass("Duplicate class: {0}"),
- HprofRandomAccessParser_Error_IllegalDumpSegment("Illegal dump segment {0}"),
- HprofRandomAccessParser_Error_MissingClass("missing fake class {0}"),
- HprofRandomAccessParser_Error_MissingFakeClass("missing fake class"),
- Pass1Parser_Error_IllegalRecordLength("Illegal record length at byte {0}"),
- Pass1Parser_Error_IllegalType("Illegal primitive object array type"),
- Pass1Parser_Error_InvalidHeapDumpFile(
- "Error: Invalid heap dump file.\n Unsupported segment type {0} at position {1}"),
- Pass1Parser_Error_invalidHPROFFile(
- "(Possibly) Invalid HPROF file: Expected to read another {0,number} bytes, but only {1,number} bytes are available."),
- Pass1Parser_Error_NoHeapDumpIndexFound(
- "Parser found {0} HPROF dumps in file {1}. No heap dump index {2} found. See FAQ."),
- Pass1Parser_Error_SupportedDumps("Only 32bit and 64bit dumps are supported."),
- Pass1Parser_Error_UnresolvedName("Unresolved Name 0x"),
- Pass1Parser_Info_UsingDumpIndex(
- "Parser found {0} HPROF dumps in file {1}. Using dump index {2}. See FAQ."),
- Pass1Parser_Info_WroteThreadsTo("Wrote threads call stacks to {0}"),
- Pass1Parser_Error_WritingThreadsInformation("Error writing threads information"),
- Pass2Parser_Error_HandleMustCreateFakeClassForName("handler must create fake class for {0}"),
- Pass2Parser_Error_HandlerMustCreateFakeClassForAddress(
- "handler must create fake class for 0x{0}"),
- Pass2Parser_Error_InsufficientBytesRead("Insufficient bytes read for instance at {0}"),
- ClassSpecificNameResolverRegistry_Error_MissingObject(
- "No object to resolve class specific name for."),
- ClassSpecificNameResolverRegistry_ErrorMsg_DuringResolving("Error resolving name of {0}"),
- GCRootInfo_BusyMonitor("Busy Monitor"),
- GCRootInfo_Finalizable("Finalizable"),
- GCRootInfo_JavaLocal("Java Local"),
- GCRootInfo_JNIGlobal("JNI Global"),
- GCRootInfo_JNILocal("JNI Local"),
- GCRootInfo_NativeStack("Native Stack"),
- GCRootInfo_SystemClass("System Class"),
- GCRootInfo_Thread("Thread"),
- GCRootInfo_ThreadBlock("Thread Block"),
- GCRootInfo_Unfinalized("Unfinalized"),
- GCRootInfo_Unkown("Unknown"),
- GCRootInfo_Unreachable("Unreachable"),
- AbstractObjectImpl_Error_FieldContainsIllegalReference(
- "AbstractObjectImpl_Error_FieldContainsIllegalReference"),
- AbstractObjectImpl_Error_FieldIsNotReference("AbstractObjectImpl_Error_FieldIsNotReference"),
- BitOutputStream_Error_ArrayFull("BitOutputStream_Error_ArrayFull"),
- DominatorTree_CalculateRetainedSizes("DominatorTree_CalculateRetainedSizes"),
- DominatorTree_CalculatingDominatorTree("DominatorTree_CalculatingDominatorTree"),
- DominatorTree_ComputingDominators("DominatorTree_ComputingDominators"),
- DominatorTree_CreateDominatorsIndexFile("DominatorTree_CreateDominatorsIndexFile"),
- DominatorTree_DepthFirstSearch("DominatorTree_DepthFirstSearch"),
- DominatorTree_DominatorTreeCalculation("DominatorTree_DominatorTreeCalculation"),
- GarbageCleaner_ReIndexingClasses("GarbageCleaner_ReIndexingClasses"),
- GarbageCleaner_ReIndexingObjects("GarbageCleaner_ReIndexingObjects"),
- GarbageCleaner_ReIndexingOutboundIndex("GarbageCleaner_ReIndexingOutboundIndex"),
- GarbageCleaner_RemovingUnreachableObjects("GarbageCleaner_RemovingUnreachableObjects"),
- GarbageCleaner_SearchingForUnreachableObjects("GarbageCleaner_SearchingForUnreachableObjects"),
- GarbageCleaner_Writing("GarbageCleaner_Writing"),
- IndexReader_Error_IndexIsEmbedded("IndexReader_Error_IndexIsEmbedded"),
- MultiplePathsFromGCRootsComputerImpl_FindingPaths(
- "MultiplePathsFromGCRootsComputerImpl_FindingPaths"),
- SnapshotFactoryImpl_Error_NoParserRegistered("SnapshotFactoryImpl_Error_NoParserRegistered"),
- SnapshotFactoryImpl_Error_ReparsingHeapDump("SnapshotFactoryImpl_Error_ReparsingHeapDump"),
- SnapshotFactoryImpl_ReparsingHeapDumpAsIndexOutOfDate(
- "SnapshotFactoryImpl_ReparsingHeapDumpAsIndexOutOfDate"),
- SnapshotFactoryImpl_ReparsingHeapDumpWithOutOfDateIndex(
- "SnapshotFactoryImpl_ReparsingHeapDumpWithOutOfDateIndex"),
- SnapshotImpl_Error_DomTreeNotAvailable("SnapshotImpl_Error_DomTreeNotAvailable"),
- SnapshotImpl_Error_ObjectNotFound("SnapshotImpl_Error_ObjectNotFound"),
- SnapshotImpl_Error_ParserNotFound("SnapshotImpl_Error_ParserNotFound"),
- SnapshotImpl_Error_ReplacingNonExistentClassLoader(
- "SnapshotImpl_Error_ReplacingNonExistentClassLoader"),
- SnapshotImpl_Error_UnknownVersion("SnapshotImpl_Error_UnknownVersion"),
- SnapshotImpl_Error_UnrecognizedState("SnapshotImpl_Error_UnrecognizedState"),
- SnapshotImpl_Label("SnapshotImpl_Label"),
- SnapshotImpl_ReadingInboundReferrers("SnapshotImpl_ReadingInboundReferrers"),
- SnapshotImpl_ReadingOutboundReferrers("SnapshotImpl_ReadingOutboundReferrers"),
- SnapshotImpl_ReopeningParsedHeapDumpFile("SnapshotImpl_ReopeningParsedHeapDumpFile"),
- SnapshotImpl_RetrievingDominators("SnapshotImpl_RetrievingDominators"),
- ObjectArrayImpl_forArray("ObjectArrayImpl_forArray"),
- ObjectMarker_CalculateRetainedSize("ObjectMarker_CalculateRetainedSize"),
- PositionInputStream_mark("PositionInputStream_mark"),
- PositionInputStream_reset("PositionInputStream_reset"),
- PositionInputStream_seek("PositionInputStream_seek"),
- RetainedSizeCache_ErrorReadingRetainedSizes("RetainedSizeCache_ErrorReadingRetainedSizes"),
- RetainedSizeCache_Warning_IgnoreError("RetainedSizeCache_Warning_IgnoreError"),
- QueueInt_ZeroSizeQueue("QueueInt_ZeroSizeQueue"),;
-
- public final String pattern;
-
- Messages(String pattern) {
- this.pattern = pattern;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/hprof/Pass1Parser.java b/src/main/java/org/eclipse/mat/hprof/Pass1Parser.java
deleted file mode 100644
index 267a56e..0000000
--- a/src/main/java/org/eclipse/mat/hprof/Pass1Parser.java
+++ /dev/null
@@ -1,637 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.hprof;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.HashMapLongObject;
-import org.eclipse.mat.parser.io.PositionInputStream;
-import org.eclipse.mat.parser.model.ClassImpl;
-import org.eclipse.mat.snapshot.model.Field;
-import org.eclipse.mat.snapshot.model.FieldDescriptor;
-import org.eclipse.mat.snapshot.model.GCRootInfo;
-import org.eclipse.mat.snapshot.model.IClass;
-import org.eclipse.mat.snapshot.model.IPrimitiveArray;
-import org.eclipse.mat.util.IProgressListener;
-import org.eclipse.mat.util.IProgressListener.Severity;
-import org.eclipse.mat.util.MessageUtil;
-import org.eclipse.mat.util.SimpleMonitor;
-
-public class Pass1Parser extends AbstractParser {
- private static final Pattern PATTERN_OBJ_ARRAY = Pattern.compile("^(\\[+)L(.*);$"); //$NON-NLS-1$
- private static final Pattern PATTERN_PRIMITIVE_ARRAY = Pattern.compile("^(\\[+)(.)$");
- //$NON-NLS-1$
-
- private HashMapLongObject<String> class2name = new HashMapLongObject<String>();
- private HashMapLongObject<Long> thread2id = new HashMapLongObject<Long>();
- private HashMapLongObject<StackFrame> id2frame = new HashMapLongObject<StackFrame>();
- private HashMapLongObject<StackTrace> serNum2stackTrace = new HashMapLongObject<StackTrace>();
- private HashMapLongObject<Long> classSerNum2id = new HashMapLongObject<Long>();
- private HashMapLongObject<List<JavaLocal>> thread2locals =
- new HashMapLongObject<List<JavaLocal>>();
- private IHprofParserHandler handler;
- private SimpleMonitor.Listener monitor;
-
- public Pass1Parser(IHprofParserHandler handler, SimpleMonitor.Listener monitor) {
- this.handler = handler;
- this.monitor = monitor;
- }
-
- public void read(File file) throws SnapshotException, IOException {
- in = new PositionInputStream(new BufferedInputStream(new FileInputStream(file)));
-
- final int dumpNrToRead = determineDumpNumber();
- int currentDumpNr = 0;
-
- try {
- // header & version
- version = readVersion(in);
- handler.addProperty(IHprofParserHandler.VERSION, version.toString());
-
- // identifierSize (32 or 64 bit)
- idSize = in.readInt();
- if (idSize != 4 && idSize != 8) {
- throw new SnapshotException(Messages.Pass1Parser_Error_SupportedDumps);
- }
- handler.addProperty(IHprofParserHandler.IDENTIFIER_SIZE, String.valueOf(idSize));
-
- // creation date
- long date = in.readLong();
- handler.addProperty(IHprofParserHandler.CREATION_DATE, String.valueOf(date));
-
- long fileSize = file.length();
- long curPos = in.position();
-
- while (curPos < fileSize) {
- if (monitor.isProbablyCanceled()) throw new IProgressListener.OperationCanceledException();
- monitor.totalWorkDone(curPos / 1000);
-
- int record = in.readUnsignedByte();
-
- in.skipBytes(4); // time stamp
-
- long length = readUnsignedInt();
- if (length < 0) {
- throw new SnapshotException(
- MessageUtil.format(Messages.Pass1Parser_Error_IllegalRecordLength, in.position()));
- }
-
- if (curPos + length - 9 > fileSize) {
- monitor.sendUserMessage(Severity.WARNING,
- MessageUtil.format(Messages.Pass1Parser_Error_invalidHPROFFile, length,
- fileSize - curPos - 9), null);
- }
-
- switch (record) {
- case Constants.Record.STRING_IN_UTF8:
- readString(length);
- break;
- case Constants.Record.LOAD_CLASS:
- readLoadClass();
- break;
- case Constants.Record.STACK_FRAME:
- readStackFrame(length);
- break;
- case Constants.Record.STACK_TRACE:
- readStackTrace(length);
- break;
- case Constants.Record.HEAP_DUMP:
- case Constants.Record.HEAP_DUMP_SEGMENT:
- if (dumpNrToRead == currentDumpNr) {
- readDumpSegments(length);
- } else {
- in.skipBytes(length);
- }
-
- if (record == Constants.Record.HEAP_DUMP) currentDumpNr++;
-
- break;
- case Constants.Record.HEAP_DUMP_END:
- currentDumpNr++;
- default:
- in.skipBytes(length);
- break;
- }
-
- curPos = in.position();
- }
- } finally {
- try {
- in.close();
- } catch (IOException ignore) {
- }
- }
-
- if (currentDumpNr <= dumpNrToRead) {
- throw new SnapshotException(
- MessageUtil.format(Messages.Pass1Parser_Error_NoHeapDumpIndexFound, currentDumpNr,
- file.getName(), dumpNrToRead));
- }
-
- if (currentDumpNr > 1) {
- monitor.sendUserMessage(IProgressListener.Severity.INFO,
- MessageUtil.format(Messages.Pass1Parser_Info_UsingDumpIndex, currentDumpNr,
- file.getName(), dumpNrToRead), null);
- }
-
- if (serNum2stackTrace.size() > 0) dumpThreads();
- }
-
- private void readString(long length) throws IOException {
- long id = readID();
- byte[] chars = new byte[(int) (length - idSize)];
- in.readFully(chars);
- handler.getConstantPool().put(id, new String(chars));
- }
-
- private void readLoadClass() throws IOException {
- long classSerNum = readUnsignedInt(); // used in stacks frames
- long classID = readID();
- in.skipBytes(4);
- long nameID = readID();
-
- String className = getStringConstant(nameID).replace('/', '.');
- class2name.put(classID, className);
- classSerNum2id.put(classSerNum, classID);
- }
-
- private void readStackFrame(long length) throws IOException {
- long frameId = readID();
- long methodName = readID();
- long methodSig = readID();
- long srcFile = readID();
- long classSerNum = readUnsignedInt();
- int lineNr = in.readInt(); // can be negative
- StackFrame frame =
- new StackFrame(frameId, lineNr, getStringConstant(methodName), getStringConstant(methodSig),
- getStringConstant(srcFile), classSerNum);
- id2frame.put(frameId, frame);
- }
-
- private void readStackTrace(long length) throws IOException {
- long stackTraceNr = readUnsignedInt();
- long threadNr = readUnsignedInt();
- long frameCount = readUnsignedInt();
- long[] frameIds = new long[(int) frameCount];
- for (int i = 0; i < frameCount; i++) {
- frameIds[i] = readID();
- }
- StackTrace stackTrace = new StackTrace(stackTraceNr, threadNr, frameIds);
- serNum2stackTrace.put(stackTraceNr, stackTrace);
- }
-
- private void readDumpSegments(long length) throws IOException, SnapshotException {
- long segmentStartPos = in.position();
- long segmentsEndPos = segmentStartPos + length;
-
- while (segmentStartPos < segmentsEndPos) {
- long workDone = segmentStartPos / 1000;
- if (this.monitor.getWorkDone() < workDone) {
- if (this.monitor.isProbablyCanceled()) {
- throw new IProgressListener.OperationCanceledException();
- }
- this.monitor.totalWorkDone(workDone);
- }
-
- int segmentType = in.readUnsignedByte();
- switch (segmentType) {
- case Constants.DumpSegment.ROOT_UNKNOWN:
- readGC(GCRootInfo.Type.UNKNOWN, 0);
- break;
- case Constants.DumpSegment.ROOT_THREAD_OBJECT:
- readGCThreadObject(GCRootInfo.Type.THREAD_OBJ);
- break;
- case Constants.DumpSegment.ROOT_JNI_GLOBAL:
- readGC(GCRootInfo.Type.NATIVE_STACK, idSize);
- break;
- case Constants.DumpSegment.ROOT_JNI_LOCAL:
- readGCWithThreadContext(GCRootInfo.Type.NATIVE_LOCAL, true);
- break;
- case Constants.DumpSegment.ROOT_JAVA_FRAME:
- readGCWithThreadContext(GCRootInfo.Type.JAVA_LOCAL, true);
- break;
- case Constants.DumpSegment.ROOT_NATIVE_STACK:
- readGCWithThreadContext(GCRootInfo.Type.NATIVE_STACK, false);
- break;
- case Constants.DumpSegment.ROOT_STICKY_CLASS:
- readGC(GCRootInfo.Type.SYSTEM_CLASS, 0);
- break;
- case Constants.DumpSegment.ROOT_THREAD_BLOCK:
- readGC(GCRootInfo.Type.THREAD_BLOCK, 4);
- break;
- case Constants.DumpSegment.ROOT_MONITOR_USED:
- readGC(GCRootInfo.Type.BUSY_MONITOR, 0);
- break;
- case Constants.DumpSegment.CLASS_DUMP:
- readClassDump(segmentStartPos);
- break;
- case Constants.DumpSegment.INSTANCE_DUMP:
- readInstanceDump(segmentStartPos);
- break;
- case Constants.DumpSegment.OBJECT_ARRAY_DUMP:
- readObjectArrayDump(segmentStartPos);
- break;
- case Constants.DumpSegment.PRIMITIVE_ARRAY_DUMP:
- readPrimitiveArrayDump(segmentStartPos);
- break;
-
- /* these were added for Android in 1.0.3 */
- case Constants.DumpSegment.ANDROID_HEAP_DUMP_INFO:
- // no 1.0.2 equivalent for this
- in.skipBytes(idSize + 4);
- break;
- case Constants.DumpSegment.ANDROID_ROOT_INTERNED_STRING:
- readGC(GCRootInfo.Type.UNKNOWN, 0);
- break;
- case Constants.DumpSegment.ANDROID_ROOT_FINALIZING:
- readGC(GCRootInfo.Type.UNKNOWN, 0);
- break;
- case Constants.DumpSegment.ANDROID_ROOT_DEBUGGER:
- readGC(GCRootInfo.Type.UNKNOWN, 0);
- break;
- case Constants.DumpSegment.ANDROID_ROOT_REFERENCE_CLEANUP:
- readGC(GCRootInfo.Type.UNKNOWN, 0);
- break;
- case Constants.DumpSegment.ANDROID_ROOT_VM_INTERNAL:
- readGC(GCRootInfo.Type.UNKNOWN, 0);
- break;
- case Constants.DumpSegment.ANDROID_ROOT_JNI_MONITOR:
- /* keep the ident, drop the next 8 bytes */
- readGC(GCRootInfo.Type.UNKNOWN, 8);
- break;
- case Constants.DumpSegment.ANDROID_UNREACHABLE:
- readGC(GCRootInfo.Type.UNKNOWN, 0);
- break;
- case Constants.DumpSegment.ANDROID_PRIMITIVE_ARRAY_NODATA_DUMP:
- readPrimitiveArrayNoDataDump(segmentStartPos);
- break;
-
- default:
- throw new SnapshotException(
- MessageUtil.format(Messages.Pass1Parser_Error_InvalidHeapDumpFile, segmentType,
- segmentStartPos));
- }
-
- segmentStartPos = in.position();
- }
- }
-
- private void readGCThreadObject(int gcType) throws IOException {
- long id = readID();
- int threadSerialNo = in.readInt();
- thread2id.put(threadSerialNo, id);
- handler.addGCRoot(id, 0, gcType);
-
- in.skipBytes(4);
- }
-
- private void readGC(int gcType, int skip) throws IOException {
- long id = readID();
- handler.addGCRoot(id, 0, gcType);
-
- if (skip > 0) in.skipBytes(skip);
- }
-
- private void readGCWithThreadContext(int gcType, boolean hasLineInfo) throws IOException {
- long id = readID();
- int threadSerialNo = in.readInt();
- Long tid = thread2id.get(threadSerialNo);
- if (tid != null) {
- handler.addGCRoot(id, tid, gcType);
- } else {
- handler.addGCRoot(id, 0, gcType);
- }
-
- if (hasLineInfo) {
- int lineNumber = in.readInt();
- List<JavaLocal> locals = thread2locals.get(threadSerialNo);
- if (locals == null) {
- locals = new ArrayList<JavaLocal>();
- thread2locals.put(threadSerialNo, locals);
- }
- locals.add(new JavaLocal(id, lineNumber, gcType));
- }
- }
-
- private void readClassDump(long segmentStartPos) throws IOException {
- long address = readID();
- in.skipBytes(4); // stack trace serial number
- long superClassObjectId = readID();
- long classLoaderObjectId = readID();
-
- // skip signers, protection domain, reserved ids (2), instance size
- in.skipBytes(this.idSize * 4 + 4);
-
- // constant pool: u2 ( u2 u1 value )*
- int constantPoolSize = in.readUnsignedShort();
- for (int ii = 0; ii < constantPoolSize; ii++) {
- in.skipBytes(2); // index
- skipValue(); // value
- }
-
- // static fields: u2 num ( name ID, u1 type, value)
- int numStaticFields = in.readUnsignedShort();
- Field[] statics = new Field[numStaticFields];
-
- for (int ii = 0; ii < numStaticFields; ii++) {
- long nameId = readID();
- String name = getStringConstant(nameId);
-
- byte type = in.readByte();
-
- Object value = readValue(null, type);
- statics[ii] = new Field(name, type, value);
- }
-
- // instance fields: u2 num ( name ID, u1 type )
- int numInstanceFields = in.readUnsignedShort();
- FieldDescriptor[] fields = new FieldDescriptor[numInstanceFields];
-
- for (int ii = 0; ii < numInstanceFields; ii++) {
- long nameId = readID();
- String name = getStringConstant(nameId);
-
- byte type = in.readByte();
- fields[ii] = new FieldDescriptor(name, type);
- }
-
- // get name
- String className = class2name.get(address);
- if (className == null) className = "unknown-name@0x" + Long.toHexString(address); //$NON-NLS-1$
-
- if (className.charAt(0) == '[') // quick check if array at hand
- {
- // fix object class names
- Matcher matcher = PATTERN_OBJ_ARRAY.matcher(className);
- if (matcher.matches()) {
- int l = matcher.group(1).length();
- className = matcher.group(2);
- for (int ii = 0; ii < l; ii++)
- className += "[]"; //$NON-NLS-1$
- }
-
- // primitive arrays
- matcher = PATTERN_PRIMITIVE_ARRAY.matcher(className);
- if (matcher.matches()) {
- int count = matcher.group(1).length() - 1;
- className = "unknown[]"; //$NON-NLS-1$
-
- char signature = matcher.group(2).charAt(0);
- for (int ii = 0; ii < IPrimitiveArray.SIGNATURES.length; ii++) {
- if (IPrimitiveArray.SIGNATURES[ii] == (byte) signature) {
- className = IPrimitiveArray.TYPE[ii];
- break;
- }
- }
-
- for (int ii = 0; ii < count; ii++)
- className += "[]"; //$NON-NLS-1$
- }
- }
-
- ClassImpl clazz =
- new ClassImpl(address, className, superClassObjectId, classLoaderObjectId, statics, fields);
- handler.addClass(clazz, segmentStartPos);
- }
-
- private void readInstanceDump(long segmentStartPos) throws IOException {
- long address = readID();
- handler.reportInstance(address, segmentStartPos);
- in.skipBytes(idSize + 4);
- int payload = in.readInt();
- in.skipBytes(payload);
- }
-
- private void readObjectArrayDump(long segmentStartPos) throws IOException {
- long address = readID();
- handler.reportInstance(address, segmentStartPos);
-
- in.skipBytes(4);
- int size = in.readInt();
- long arrayClassObjectID = readID();
-
- // check if class needs to be created
- IClass arrayType = handler.lookupClass(arrayClassObjectID);
- if (arrayType == null) handler.reportRequiredObjectArray(arrayClassObjectID);
-
- in.skipBytes(size * idSize);
- }
-
- private void readPrimitiveArrayDump(long segmentStartPos) throws SnapshotException, IOException {
- long address = readID();
- handler.reportInstance(address, segmentStartPos);
-
- in.skipBytes(4);
- int size = in.readInt();
- byte elementType = in.readByte();
-
- if ((elementType < IPrimitiveArray.Type.BOOLEAN) || (elementType > IPrimitiveArray.Type.LONG)) {
- throw new SnapshotException(Messages.Pass1Parser_Error_IllegalType);
- }
-
- // check if class needs to be created
- String name = IPrimitiveArray.TYPE[elementType];
- IClass clazz = handler.lookupClassByName(name, true);
- if (clazz == null) handler.reportRequiredPrimitiveArray(elementType);
-
- int elementSize = IPrimitiveArray.ELEMENT_SIZE[elementType];
- in.skipBytes(elementSize * size);
- }
-
- /* Added for Android in 1.0.3 */
- private void readPrimitiveArrayNoDataDump(long segmentStartPos)
- throws SnapshotException, IOException {
-
- long address = readID();
- handler.reportInstance(address, segmentStartPos);
-
- in.skipBytes(4);
- int size = in.readInt();
- byte elementType = in.readByte();
-
- if ((elementType < IPrimitiveArray.Type.BOOLEAN) || (elementType > IPrimitiveArray.Type.LONG)) {
- throw new SnapshotException(Messages.Pass1Parser_Error_IllegalType);
- }
-
- // check if class needs to be created
- String name = IPrimitiveArray.TYPE[elementType];
- IClass clazz = handler.lookupClassByName(name, true);
- if (clazz == null) {
- handler.reportRequiredPrimitiveArray(elementType);
- }
- }
-
- private String getStringConstant(long address) {
- if (address == 0L) return ""; //$NON-NLS-1$
-
- String result = handler.getConstantPool().get(address);
- return result == null ? Messages.Pass1Parser_Error_UnresolvedName + Long.toHexString(address)
- : result;
- }
-
- private void dumpThreads() {
- // noticed that one stack trace with empty stack is always reported,
- // even if the dump has no call stacks info
- if (serNum2stackTrace == null || serNum2stackTrace.size() <= 1) return;
-
- PrintWriter out = null;
- String outputName = handler.getSnapshotInfo().getPrefix() + "threads"; //$NON-NLS-1$
- try {
- out = new PrintWriter(new FileWriter(outputName));
-
- Iterator<StackTrace> it = serNum2stackTrace.values();
- while (it.hasNext()) {
- StackTrace stack = it.next();
- Long tid = thread2id.get(stack.threadSerialNr);
- if (tid == null) continue;
- String threadId =
- tid == null ? "<unknown>" : "0x" + Long.toHexString(tid); //$NON-NLS-1$ //$NON-NLS-2$
- out.println("Thread " + threadId); //$NON-NLS-1$
- out.println(stack);
- out.println(" locals:"); //$NON-NLS-1$
- List<JavaLocal> locals = thread2locals.get(stack.threadSerialNr);
- if (locals != null) {
- for (JavaLocal javaLocal : locals) {
- out.println(" objecId=0x"
- + Long.toHexString(javaLocal.objectId)
- + ", line="
- + javaLocal.lineNumber); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- out.println();
- }
- out.flush();
- this.monitor.sendUserMessage(Severity.INFO,
- MessageUtil.format(Messages.Pass1Parser_Info_WroteThreadsTo, outputName), null);
- } catch (IOException e) {
- this.monitor.sendUserMessage(Severity.WARNING,
- MessageUtil.format(Messages.Pass1Parser_Error_WritingThreadsInformation), e);
- } finally {
- if (out != null) {
- try {
- out.close();
- } catch (Exception ignore) {
- // $JL-EXC$
- }
- }
- }
- }
-
- private class StackFrame {
- final long frameId;
- final String method;
- final String methodSignature;
- final String sourceFile;
- final long classSerNum;
-
- /*
- * > 0 line number
- * 0 no line info
- * -1 unknown location
- * -2 compiled method
- * -3 native method
- */
- final int lineNr;
-
- public StackFrame(long frameId, int lineNr, String method, String methodSignature,
- String sourceFile, long classSerNum) {
- this.frameId = frameId;
- this.lineNr = lineNr;
- this.method = method;
- this.methodSignature = methodSignature;
- this.sourceFile = sourceFile;
- this.classSerNum = classSerNum;
- }
-
- @Override public String toString() {
- String className = null;
- Long classId = classSerNum2id.get(classSerNum);
- if (classId == null) {
- className = "<UNKNOWN CLASS>"; //$NON-NLS-1$
- } else {
- className = class2name.get(classId);
- }
-
- String sourceLocation = ""; //$NON-NLS-1$
- if (lineNr > 0) {
- sourceLocation = "("
- + sourceFile
- + ":"
- + String.valueOf(lineNr)
- + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else if (lineNr == 0 || lineNr == -1) {
- sourceLocation = "(Unknown Source)"; //$NON-NLS-1$
- } else if (lineNr == -2) {
- sourceLocation = "(Compiled method)"; //$NON-NLS-1$
- } else if (lineNr == -3) {
- sourceLocation = "(Native Method)"; //$NON-NLS-1$
- }
-
- return " at "
- + className
- + "."
- + method
- + methodSignature
- + " "
- + sourceLocation; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- private class StackTrace {
- final long threadSerialNr;
- final long[] frameIds;
-
- public StackTrace(long serialNr, long threadSerialNr, long[] frameIds) {
- this.threadSerialNr = threadSerialNr;
- this.frameIds = frameIds;
- }
-
- @Override public String toString() {
- StringBuilder b = new StringBuilder();
- for (long frameId : frameIds) {
- StackFrame frame = id2frame.get(frameId);
- if (frame != null) {
- b.append(frame).append("\r\n"); //$NON-NLS-1$
- }
- }
- return b.toString();
- }
- }
-
- private static class JavaLocal {
-
- final long objectId;
- final int lineNumber;
- final int type;
-
- public JavaLocal(long objectId, int lineNumber, int type) {
- this.objectId = objectId;
- this.lineNumber = lineNumber;
- this.type = type;
- }
-
- public int getType() {
- return type;
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/hprof/Pass2Parser.java b/src/main/java/org/eclipse/mat/hprof/Pass2Parser.java
deleted file mode 100644
index 3c8c6ad..0000000
--- a/src/main/java/org/eclipse/mat/hprof/Pass2Parser.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.hprof;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.lang.ref.PhantomReference;
-import java.lang.ref.SoftReference;
-import java.lang.ref.WeakReference;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.hprof.IHprofParserHandler.HeapObject;
-import org.eclipse.mat.parser.io.PositionInputStream;
-import org.eclipse.mat.parser.model.ClassImpl;
-import org.eclipse.mat.parser.model.ObjectArrayImpl;
-import org.eclipse.mat.parser.model.PrimitiveArrayImpl;
-import org.eclipse.mat.snapshot.model.FieldDescriptor;
-import org.eclipse.mat.snapshot.model.IClass;
-import org.eclipse.mat.snapshot.model.IObject;
-import org.eclipse.mat.snapshot.model.IPrimitiveArray;
-import org.eclipse.mat.util.IProgressListener;
-import org.eclipse.mat.util.MessageUtil;
-import org.eclipse.mat.util.SimpleMonitor;
-
-/**
- * Parser used to read the hprof formatted heap dump
- */
-public class Pass2Parser extends AbstractParser {
- private IHprofParserHandler handler;
- private SimpleMonitor.Listener monitor;
-
- public Pass2Parser(IHprofParserHandler handler, SimpleMonitor.Listener monitor) {
- this.handler = handler;
- this.monitor = monitor;
- }
-
- public void read(File file) throws SnapshotException, IOException {
- in = new PositionInputStream(new BufferedInputStream(new FileInputStream(file)));
-
- final int dumpNrToRead = determineDumpNumber();
- int currentDumpNr = 0;
-
- try {
- version = readVersion(in);
- idSize = in.readInt();
- if (idSize != 4 && idSize != 8) {
- throw new SnapshotException(Messages.Pass1Parser_Error_SupportedDumps);
- }
- in.skipBytes(8); // creation date
-
- long fileSize = file.length();
- long curPos = in.position();
-
- while (curPos < fileSize) {
- if (monitor.isProbablyCanceled()) throw new IProgressListener.OperationCanceledException();
- monitor.totalWorkDone(curPos / 1000);
-
- int record = in.readUnsignedByte();
-
- in.skipBytes(4); // time stamp
-
- long length = readUnsignedInt();
- if (length < 0) {
- throw new SnapshotException(
- MessageUtil.format(Messages.Pass1Parser_Error_IllegalRecordLength, in.position()));
- }
-
- switch (record) {
- case Constants.Record.HEAP_DUMP:
- case Constants.Record.HEAP_DUMP_SEGMENT:
- if (dumpNrToRead == currentDumpNr) {
- readDumpSegments(length);
- } else {
- in.skipBytes(length);
- }
-
- if (record == Constants.Record.HEAP_DUMP) currentDumpNr++;
-
- break;
- case Constants.Record.HEAP_DUMP_END:
- currentDumpNr++;
- default:
- in.skipBytes(length);
- break;
- }
-
- curPos = in.position();
- }
- } finally {
- try {
- in.close();
- } catch (IOException ignore) {
- }
- }
- }
-
- private void readDumpSegments(long length) throws SnapshotException, IOException {
- long segmentStartPos = in.position();
- long segmentsEndPos = segmentStartPos + length;
-
- while (segmentStartPos < segmentsEndPos) {
- long workDone = segmentStartPos / 1000;
- if (this.monitor.getWorkDone() < workDone) {
- if (this.monitor.isProbablyCanceled()) {
- throw new IProgressListener.OperationCanceledException();
- }
- this.monitor.totalWorkDone(workDone);
- }
-
- int segmentType = in.readUnsignedByte();
- switch (segmentType) {
- case Constants.DumpSegment.ROOT_UNKNOWN:
- case Constants.DumpSegment.ROOT_STICKY_CLASS:
- case Constants.DumpSegment.ROOT_MONITOR_USED:
- in.skipBytes(idSize);
- break;
- case Constants.DumpSegment.ROOT_JNI_GLOBAL:
- in.skipBytes(idSize * 2);
- break;
- case Constants.DumpSegment.ROOT_NATIVE_STACK:
- case Constants.DumpSegment.ROOT_THREAD_BLOCK:
- in.skipBytes(idSize + 4);
- break;
- case Constants.DumpSegment.ROOT_THREAD_OBJECT:
- case Constants.DumpSegment.ROOT_JNI_LOCAL:
- case Constants.DumpSegment.ROOT_JAVA_FRAME:
- in.skipBytes(idSize + 8);
- break;
- case Constants.DumpSegment.CLASS_DUMP:
- skipClassDump();
- break;
- case Constants.DumpSegment.INSTANCE_DUMP:
- readInstanceDump(segmentStartPos);
- break;
- case Constants.DumpSegment.OBJECT_ARRAY_DUMP:
- readObjectArrayDump(segmentStartPos);
- break;
- case Constants.DumpSegment.PRIMITIVE_ARRAY_DUMP:
- readPrimitiveArrayDump(segmentStartPos);
- break;
-
- /* these were added for Android in 1.0.3 */
- case Constants.DumpSegment.ANDROID_HEAP_DUMP_INFO:
- in.skipBytes(idSize + 4);
- break;
- case Constants.DumpSegment.ANDROID_ROOT_INTERNED_STRING:
- case Constants.DumpSegment.ANDROID_ROOT_FINALIZING:
- case Constants.DumpSegment.ANDROID_ROOT_DEBUGGER:
- case Constants.DumpSegment.ANDROID_ROOT_REFERENCE_CLEANUP:
- case Constants.DumpSegment.ANDROID_ROOT_VM_INTERNAL:
- case Constants.DumpSegment.ANDROID_UNREACHABLE:
- in.skipBytes(idSize);
- break;
- case Constants.DumpSegment.ANDROID_ROOT_JNI_MONITOR:
- in.skipBytes(idSize + 8);
- break;
- case Constants.DumpSegment.ANDROID_PRIMITIVE_ARRAY_NODATA_DUMP:
- readPrimitiveArrayNoDataDump(segmentStartPos);
- break;
-
- default:
- throw new SnapshotException(
- MessageUtil.format(Messages.Pass1Parser_Error_InvalidHeapDumpFile, segmentType,
- segmentStartPos));
- }
- segmentStartPos = in.position();
- }
- }
-
- private void skipClassDump() throws IOException {
- in.skipBytes(7 * idSize + 8);
-
- int constantPoolSize = in.readUnsignedShort();
- for (int ii = 0; ii < constantPoolSize; ii++) {
- in.skipBytes(2);
- skipValue();
- }
-
- int numStaticFields = in.readUnsignedShort();
- for (int i = 0; i < numStaticFields; i++) {
- in.skipBytes(idSize);
- skipValue();
- }
-
- int numInstanceFields = in.readUnsignedShort();
- in.skipBytes((idSize + 1) * numInstanceFields);
- }
-
- static final Set<String> ignorableClasses = new HashSet<String>();
-
- static {
- ignorableClasses.add(WeakReference.class.getName());
- ignorableClasses.add(SoftReference.class.getName());
- ignorableClasses.add(PhantomReference.class.getName());
- ignorableClasses.add("java.lang.ref.Finalizer");
- ignorableClasses.add("java.lang.ref.FinalizerReference");
- }
-
- private void readInstanceDump(long segmentStartPos) throws IOException {
- long id = readID();
- in.skipBytes(4);
- long classID = readID();
- int bytesFollowing = in.readInt();
- long endPos = in.position() + bytesFollowing;
-
- List<IClass> hierarchy = handler.resolveClassHierarchy(classID);
-
- ClassImpl thisClazz = (ClassImpl) hierarchy.get(0);
- HeapObject heapObject = new HeapObject(handler.mapAddressToId(id), id, thisClazz,
- thisClazz.getHeapSizePerInstance());
-
- heapObject.references.add(thisClazz.getObjectAddress());
-
- // extract outgoing references
- boolean isWeakReferenceClass = false;
- for (IClass clazz : hierarchy) {
- if (ignorableClasses.contains(clazz.getName())) {
- isWeakReferenceClass = true;
- break;
- }
- }
- for (IClass clazz : hierarchy) {
- for (FieldDescriptor field : clazz.getFieldDescriptors()) {
- int type = field.getType();
- if (type == IObject.Type.OBJECT) {
- long refId = readID();
- if (refId != 0 && !(isWeakReferenceClass && field.getName().equals("referent"))) {
- heapObject.references.add(refId);
- }
- } else {
- skipValue(type);
- }
- }
- }
-
- if (endPos != in.position()) {
- throw new IOException(
- MessageUtil.format(Messages.Pass2Parser_Error_InsufficientBytesRead, segmentStartPos));
- }
-
- handler.addObject(heapObject, segmentStartPos);
- }
-
- private void readObjectArrayDump(long segmentStartPos) throws IOException {
- long id = readID();
-
- in.skipBytes(4);
- int size = in.readInt();
- long arrayClassObjectID = readID();
-
- ClassImpl arrayType = (ClassImpl) handler.lookupClass(arrayClassObjectID);
- if (arrayType == null) {
- throw new RuntimeException(
- MessageUtil.format(Messages.Pass2Parser_Error_HandlerMustCreateFakeClassForAddress,
- Long.toHexString(arrayClassObjectID)));
- }
-
- HeapObject heapObject = new HeapObject(handler.mapAddressToId(id), id, arrayType,
- ObjectArrayImpl.doGetUsedHeapSize(arrayType, size));
- heapObject.references.add(arrayType.getObjectAddress());
- heapObject.isArray = true;
-
- for (int ii = 0; ii < size; ii++) {
- long refId = readID();
- if (refId != 0) heapObject.references.add(refId);
- }
-
- handler.addObject(heapObject, segmentStartPos);
- }
-
- private void readPrimitiveArrayDump(long segmentStartPost) throws SnapshotException, IOException {
- long id = readID();
-
- in.skipBytes(4);
- int size = in.readInt();
- byte elementType = in.readByte();
-
- if ((elementType < IPrimitiveArray.Type.BOOLEAN) || (elementType > IPrimitiveArray.Type.LONG)) {
- throw new SnapshotException(Messages.Pass1Parser_Error_IllegalType);
- }
-
- String name = IPrimitiveArray.TYPE[elementType];
- ClassImpl clazz = (ClassImpl) handler.lookupClassByName(name, true);
- if (clazz == null) {
- throw new RuntimeException(
- MessageUtil.format(Messages.Pass2Parser_Error_HandleMustCreateFakeClassForName, name));
- }
-
- HeapObject heapObject = new HeapObject(handler.mapAddressToId(id), id, clazz,
- PrimitiveArrayImpl.doGetUsedHeapSize(clazz, size, elementType));
- heapObject.references.add(clazz.getObjectAddress());
- heapObject.isArray = true;
-
- handler.addObject(heapObject, segmentStartPost);
-
- int elementSize = IPrimitiveArray.ELEMENT_SIZE[elementType];
- in.skipBytes(elementSize * size);
- }
-
- /* Added for Android in 1.0.3 */
- private void readPrimitiveArrayNoDataDump(long segmentStartPost)
- throws SnapshotException, IOException {
-
- long id = readID();
-
- in.skipBytes(4);
- int size = in.readInt();
- byte elementType = in.readByte();
-
- if ((elementType < IPrimitiveArray.Type.BOOLEAN) || (elementType > IPrimitiveArray.Type.LONG)) {
- throw new SnapshotException(Messages.Pass1Parser_Error_IllegalType);
- }
-
- String name = IPrimitiveArray.TYPE[elementType];
- ClassImpl clazz = (ClassImpl) handler.lookupClassByName(name, true);
- if (clazz == null) {
- throw new RuntimeException(
- MessageUtil.format(Messages.Pass2Parser_Error_HandleMustCreateFakeClassForName, name));
- }
-
- HeapObject heapObject = new HeapObject(handler.mapAddressToId(id), id, clazz,
- PrimitiveArrayImpl.doGetUsedHeapSize(clazz, size, elementType));
- heapObject.references.add(clazz.getObjectAddress());
- heapObject.isArray = true;
-
- handler.addObject(heapObject, segmentStartPost);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/hprof/extension/IParsingEnhancer.java b/src/main/java/org/eclipse/mat/hprof/extension/IParsingEnhancer.java
deleted file mode 100644
index 19a3982..0000000
--- a/src/main/java/org/eclipse/mat/hprof/extension/IParsingEnhancer.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.hprof.extension;
-
-import java.io.IOException;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.snapshot.SnapshotInfo;
-
-public interface IParsingEnhancer {
- void onParsingCompleted(SnapshotInfo snapshotInfo) throws SnapshotException, IOException;
-}
diff --git a/src/main/java/org/eclipse/mat/hprof/extension/IRuntimeEnhancer.java b/src/main/java/org/eclipse/mat/hprof/extension/IRuntimeEnhancer.java
deleted file mode 100644
index f708574..0000000
--- a/src/main/java/org/eclipse/mat/hprof/extension/IRuntimeEnhancer.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.hprof.extension;
-
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.snapshot.ISnapshot;
-
-public interface IRuntimeEnhancer {
- <A> A getAddon(ISnapshot snapshot, Class<A> addon) throws SnapshotException;
-}
diff --git a/src/main/java/org/eclipse/mat/inspections/CommonNameResolver.java b/src/main/java/org/eclipse/mat/inspections/CommonNameResolver.java
deleted file mode 100644
index 3a37f0e..0000000
--- a/src/main/java/org/eclipse/mat/inspections/CommonNameResolver.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.inspections;
-
-import java.lang.reflect.Modifier;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.snapshot.ISnapshot;
-import org.eclipse.mat.snapshot.extension.IClassSpecificNameResolver;
-import org.eclipse.mat.snapshot.extension.Subject;
-import org.eclipse.mat.snapshot.extension.Subjects;
-import org.eclipse.mat.snapshot.model.IClass;
-import org.eclipse.mat.snapshot.model.IObject;
-import org.eclipse.mat.snapshot.model.IObjectArray;
-import org.eclipse.mat.snapshot.model.IPrimitiveArray;
-import org.eclipse.mat.snapshot.model.PrettyPrinter;
-
-public class CommonNameResolver {
- @Subject("java.lang.String") public static class StringResolver
- implements IClassSpecificNameResolver {
- public String resolve(IObject obj) throws SnapshotException {
- return PrettyPrinter.objectAsString(obj, 1024);
- }
- }
-
- @Subjects({
- "java.lang.StringBuffer", //
- "java.lang.StringBuilder"
- }) public static class StringBufferResolver implements IClassSpecificNameResolver {
- public String resolve(IObject obj) throws SnapshotException {
- Integer count = (Integer) obj.resolveValue("count"); //$NON-NLS-1$
- if (count == null) return null;
- if (count == 0) return ""; //$NON-NLS-1$
-
- IPrimitiveArray charArray = (IPrimitiveArray) obj.resolveValue("value"); //$NON-NLS-1$
- if (charArray == null) return null;
-
- return PrettyPrinter.arrayAsString(charArray, 0, count, 1024);
- }
- }
-
- @Subject("java.lang.Thread") public static class ThreadResolver
- implements IClassSpecificNameResolver {
- public String resolve(IObject obj) throws SnapshotException {
- IObject name = (IObject) obj.resolveValue("name"); //$NON-NLS-1$
- return name != null ? name.getClassSpecificName() : null;
- }
- }
-
- @Subject("java.lang.ThreadGroup") public static class ThreadGroupResolver
- implements IClassSpecificNameResolver {
- public String resolve(IObject object) throws SnapshotException {
- IObject nameString = (IObject) object.resolveValue("name"); //$NON-NLS-1$
- if (nameString == null) return null;
- return nameString.getClassSpecificName();
- }
- }
-
- @Subjects({
- "java.lang.Byte", //
- "java.lang.Character", //
- "java.lang.Short", //
- "java.lang.Integer", //
- "java.lang.Long", //
- "java.lang.Float", //
- "java.lang.Double", //
- "java.lang.Boolean"
- }) public static class ValueResolver implements IClassSpecificNameResolver {
- public String resolve(IObject heapObject) throws SnapshotException {
- return String.valueOf(heapObject.resolveValue("value")); //$NON-NLS-1$
- }
- }
-
- @Subject("char[]") public static class CharArrayResolver implements IClassSpecificNameResolver {
- public String resolve(IObject heapObject) throws SnapshotException {
- IPrimitiveArray charArray = (IPrimitiveArray) heapObject;
- return PrettyPrinter.arrayAsString(charArray, 0, charArray.getLength(), 1024);
- }
- }
-
- @Subject("byte[]") public static class ByteArrayResolver implements IClassSpecificNameResolver {
- public String resolve(IObject heapObject) throws SnapshotException {
- IPrimitiveArray arr = (IPrimitiveArray) heapObject;
- byte[] value = (byte[]) arr.getValueArray(0, Math.min(arr.getLength(), 1024));
- if (value == null) return null;
-
- // must not modify the original byte array
- StringBuilder r = new StringBuilder(value.length);
- for (int i = 0; i < value.length; i++) {
- // ASCII/Unicode 127 is not printable
- if (value[i] < 32 || value[i] > 126) {
- r.append('.');
- } else {
- r.append((char) value[i]);
- }
- }
- return r.toString();
- }
- }
-
- /*
- * Contributed in bug 273915
- */
- @Subject("java.net.URL") public static class URLResolver implements IClassSpecificNameResolver {
- public String resolve(IObject obj) throws SnapshotException {
- StringBuilder builder = new StringBuilder();
- IObject protocol = (IObject) obj.resolveValue("protocol"); //$NON-NLS-1$
- builder.append(protocol.getClassSpecificName());
- builder.append(":"); //$NON-NLS-1$
- IObject authority = (IObject) obj.resolveValue("authority"); //$NON-NLS-1$
- if (authority != null) {
- builder.append("//"); //$NON-NLS-1$
- builder.append(authority.getClassSpecificName());
- }
- IObject path = (IObject) obj.resolveValue("path"); //$NON-NLS-1$
- if (path != null) builder.append(path.getClassSpecificName());
- IObject query = (IObject) obj.resolveValue("query"); //$NON-NLS-1$
- if (query != null) {
- builder.append("?"); //$NON-NLS-1$
- builder.append(query.getClassSpecificName());
- }
- IObject ref = (IObject) obj.resolveValue("ref"); //$NON-NLS-1$
- if (ref != null) {
- builder.append("#"); //$NON-NLS-1$
- builder.append(ref.getClassSpecificName());
- }
- return builder.toString();
- }
- }
-
- @Subject("java.lang.reflect.AccessibleObject") public static class AccessibleObjectResolver
- implements IClassSpecificNameResolver {
- public String resolve(IObject obj) throws SnapshotException {
- // Important fields
- // modifiers - not actually present, but present in all superclasses
- // clazz - not actually present, but present in all superclasses
- StringBuilder r = new StringBuilder();
- ISnapshot snapshot = obj.getSnapshot();
- IObject ref;
- Object val = obj.resolveValue("modifiers"); //$NON-NLS-1$
- if (val instanceof Integer) {
- r.append(Modifier.toString((Integer) val));
- if (r.length() > 0) r.append(' ');
- }
- ref = (IObject) obj.resolveValue("clazz"); //$NON-NLS-1$
- if (ref != null) {
- addClassName(snapshot, ref.getObjectAddress(), r);
- } else {
- return null;
- }
- return r.toString();
- }
-
- protected void addClassName(ISnapshot snapshot, long addr, StringBuilder r)
- throws SnapshotException {
- int id = snapshot.mapAddressToId(addr);
- IObject ox = snapshot.getObject(id);
- if (ox instanceof IClass) {
- IClass cls = (IClass) ox;
- r.append(cls.getName());
- }
- }
- }
-
- @Subject("java.lang.reflect.Field") public static class FieldResolver
- extends AccessibleObjectResolver {
- public String resolve(IObject obj) throws SnapshotException {
- // Important fields
- // modifiers
- // clazz
- // name
- // type
- StringBuilder r = new StringBuilder();
- ISnapshot snapshot = obj.getSnapshot();
- IObject ref;
- Object val = obj.resolveValue("modifiers"); //$NON-NLS-1$
- if (val instanceof Integer) {
- r.append(Modifier.toString((Integer) val));
- if (r.length() > 0) r.append(' ');
- }
- ref = (IObject) obj.resolveValue("type"); //$NON-NLS-1$
- if (ref != null) {
- addClassName(snapshot, ref.getObjectAddress(), r);
- r.append(' ');
- }
- ref = (IObject) obj.resolveValue("clazz"); //$NON-NLS-1$
- if (ref != null) {
- addClassName(snapshot, ref.getObjectAddress(), r);
- r.append('.');
- }
- ref = (IObject) obj.resolveValue("name"); //$NON-NLS-1$
- if (ref != null) {
- r.append(ref.getClassSpecificName());
- } else {
- // No method name so give up
- return null;
- }
- return r.toString();
- }
- }
-
- @Subject("java.lang.reflect.Method") public static class MethodResolver
- extends AccessibleObjectResolver {
- public String resolve(IObject obj) throws SnapshotException {
- // Important fields
- // modifiers
- // clazz
- // name
- // parameterTypes[]
- // exceptionTypes[]
- // returnType
- StringBuilder r = new StringBuilder();
- ISnapshot snapshot = obj.getSnapshot();
- IObject ref;
- Object val = obj.resolveValue("modifiers"); //$NON-NLS-1$
- if (val instanceof Integer) {
- r.append(Modifier.toString((Integer) val));
- if (r.length() > 0) r.append(' ');
- }
- ref = (IObject) obj.resolveValue("returnType"); //$NON-NLS-1$
- if (ref != null) {
- addClassName(snapshot, ref.getObjectAddress(), r);
- r.append(' ');
- }
- ref = (IObject) obj.resolveValue("clazz"); //$NON-NLS-1$
- if (ref != null) {
- addClassName(snapshot, ref.getObjectAddress(), r);
- r.append('.');
- }
- ref = (IObject) obj.resolveValue("name"); //$NON-NLS-1$
- if (ref != null) {
- r.append(ref.getClassSpecificName());
- } else {
- // No method name so give up
- return null;
- }
- r.append('(');
- ref = (IObject) obj.resolveValue("parameterTypes"); //$NON-NLS-1$
- if (ref instanceof IObjectArray) {
- IObjectArray orefa = (IObjectArray) ref;
- long refs[] = orefa.getReferenceArray();
- for (int i = 0; i < orefa.getLength(); ++i) {
- if (i > 0) r.append(',');
- long addr = refs[i];
- addClassName(snapshot, addr, r);
- }
- }
- r.append(')');
- return r.toString();
- }
- }
-
- @Subject("java.lang.reflect.Constructor") public static class ConstructorResolver
- extends AccessibleObjectResolver {
- public String resolve(IObject obj) throws SnapshotException {
- // Important fields
- // modifiers
- // clazz
- // parameterTypes[]
- // exceptionTypes[]
- StringBuilder r = new StringBuilder();
- ISnapshot snapshot = obj.getSnapshot();
- IObject ref;
- Object val = obj.resolveValue("modifiers"); //$NON-NLS-1$
- if (val instanceof Integer) {
- r.append(Modifier.toString((Integer) val));
- if (r.length() > 0) r.append(' ');
- }
- ref = (IObject) obj.resolveValue("clazz"); //$NON-NLS-1$
- if (ref != null) {
- addClassName(snapshot, ref.getObjectAddress(), r);
- } else {
- // No class name so give up
- return null;
- }
- r.append('(');
- ref = (IObject) obj.resolveValue("parameterTypes"); //$NON-NLS-1$
- if (ref instanceof IObjectArray) {
- IObjectArray orefa = (IObjectArray) ref;
- long refs[] = orefa.getReferenceArray();
- for (int i = 0; i < orefa.getLength(); ++i) {
- if (i > 0) r.append(',');
- long addr = refs[i];
- addClassName(snapshot, addr, r);
- }
- }
- r.append(')');
- return r.toString();
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/IIndexBuilder.java b/src/main/java/org/eclipse/mat/parser/IIndexBuilder.java
deleted file mode 100644
index bf1c830..0000000
--- a/src/main/java/org/eclipse/mat/parser/IIndexBuilder.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser;
-
-import java.io.File;
-import java.io.IOException;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.util.IProgressListener;
-
-public interface IIndexBuilder {
- /* initialize with file and prefix (needed for naming conventions) */
- void init(File file, String prefix) throws SnapshotException, IOException;
-
- /* hprof: pass1 and pass2 parsing */
- void fill(IPreliminaryIndex index, IProgressListener listener)
- throws SnapshotException, IOException;
-
- /* hprof: update object 2 file position index */
- void clean(final int[] purgedMapping, IProgressListener listener) throws IOException;
-
- /* called in case of error to delete any files / close any file handles */
- void cancel();
-}
diff --git a/src/main/java/org/eclipse/mat/parser/IObjectReader.java b/src/main/java/org/eclipse/mat/parser/IObjectReader.java
deleted file mode 100644
index 85a70dc..0000000
--- a/src/main/java/org/eclipse/mat/parser/IObjectReader.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser;
-
-import java.io.IOException;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.parser.model.ObjectArrayImpl;
-import org.eclipse.mat.parser.model.PrimitiveArrayImpl;
-import org.eclipse.mat.snapshot.ISnapshot;
-import org.eclipse.mat.snapshot.model.IObject;
-
-public interface IObjectReader {
- void open(ISnapshot snapshot) //
- throws SnapshotException, IOException;
-
- IObject read(int objectId, ISnapshot snapshot) //
- throws SnapshotException, IOException;
-
- Object readPrimitiveArrayContent(PrimitiveArrayImpl array, int offset, int length) //
- throws IOException, SnapshotException;
-
- long[] readObjectArrayContent(ObjectArrayImpl array, int offset, int length) //
- throws IOException, SnapshotException;
-
- <A> A getAddon(Class<A> addon) //
- throws SnapshotException;
-
- void close() throws IOException;
-}
diff --git a/src/main/java/org/eclipse/mat/parser/IPreliminaryIndex.java b/src/main/java/org/eclipse/mat/parser/IPreliminaryIndex.java
deleted file mode 100644
index b463343..0000000
--- a/src/main/java/org/eclipse/mat/parser/IPreliminaryIndex.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser;
-
-import java.util.List;
-import org.eclipse.mat.collect.HashMapIntObject;
-import org.eclipse.mat.parser.index.IIndexReader;
-import org.eclipse.mat.parser.model.ClassImpl;
-import org.eclipse.mat.parser.model.XGCRootInfo;
-import org.eclipse.mat.parser.model.XSnapshotInfo;
-
-/**
- * @noimplement
- */
-public interface IPreliminaryIndex {
- XSnapshotInfo getSnapshotInfo();
-
- void setClassesById(HashMapIntObject<ClassImpl> classesById);
-
- void setGcRoots(HashMapIntObject<List<XGCRootInfo>> gcRoots);
-
- void setThread2objects2roots(
- HashMapIntObject<HashMapIntObject<List<XGCRootInfo>>> thread2objects2roots);
-
- void setOutbound(IIndexReader.IOne2ManyIndex outbound);
-
- void setIdentifiers(IIndexReader.IOne2LongIndex identifiers);
-
- void setObject2classId(IIndexReader.IOne2OneIndex object2classId);
-
- void setArray2size(IIndexReader.IOne2OneIndex array2size);
-}
diff --git a/src/main/java/org/eclipse/mat/parser/index/IIndexReader.java b/src/main/java/org/eclipse/mat/parser/index/IIndexReader.java
deleted file mode 100644
index aaaaec0..0000000
--- a/src/main/java/org/eclipse/mat/parser/index/IIndexReader.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.index;
-
-import java.io.IOException;
-import java.io.Serializable;
-import org.eclipse.mat.SnapshotException;
-
-public interface IIndexReader {
- public interface IOne2OneIndex extends IIndexReader {
- int get(int index);
-
- int[] getAll(int index[]);
-
- int[] getNext(int index, int length);
- }
-
- public interface IOne2LongIndex extends IIndexReader {
- long get(int index);
-
- int reverse(long value);
-
- long[] getNext(int index, int length);
- }
-
- public interface IOne2ManyIndex extends IIndexReader {
- int[] get(int index);
- }
-
- public interface IOne2ManyObjectsIndex extends IOne2ManyIndex {
- int[] getObjectsOf(Serializable key) throws SnapshotException, IOException;
- }
-
- int size();
-
- void unload() throws IOException;
-
- void close() throws IOException;
-
- void delete();
-}
diff --git a/src/main/java/org/eclipse/mat/parser/index/IndexManager.java b/src/main/java/org/eclipse/mat/parser/index/IndexManager.java
deleted file mode 100644
index f30bbd6..0000000
--- a/src/main/java/org/eclipse/mat/parser/index/IndexManager.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.index;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.text.MessageFormat;
-
-public class IndexManager {
- public enum Index {
- INBOUND("inbound", IndexReader.InboundReader.class), //$NON-NLS-1$
- OUTBOUND("outbound", IndexReader.IntIndex1NSortedReader.class), //$NON-NLS-1$
- O2CLASS("o2c", IndexReader.IntIndexReader.class), //$NON-NLS-1$
- IDENTIFIER("idx", IndexReader.LongIndexReader.class), //$NON-NLS-1$
- A2SIZE("a2s", IndexReader.IntIndexReader.class), //$NON-NLS-1$
- DOMINATED("domOut", IndexReader.IntIndex1NReader.class), //$NON-NLS-1$
- O2RETAINED("o2ret", IndexReader.LongIndexReader.class), //$NON-NLS-1$
- DOMINATOR("domIn", IndexReader.IntIndexReader.class);//$NON-NLS-1$
-
- public String filename;
- Class<? extends IIndexReader> impl;
-
- private Index(String filename, Class<? extends IIndexReader> impl) {
- this.filename = filename;
- this.impl = impl;
- }
-
- public File getFile(String prefix) {
- return new File(
- new StringBuilder(prefix).append(filename).append(".index").toString());//$NON-NLS-1$
- }
-
- }
-
- public IIndexReader.IOne2ManyObjectsIndex inbound;
- public IIndexReader.IOne2ManyIndex outbound;
- public IIndexReader.IOne2OneIndex o2c;
- public IIndexReader.IOne2LongIndex idx;
- public IIndexReader.IOne2OneIndex a2s;
- public IIndexReader.IOne2ManyIndex domOut;
- public IIndexReader.IOne2LongIndex o2ret;
- public IIndexReader.IOne2OneIndex domIn;
-
- public void setReader(final Index index, final IIndexReader reader) {
- try {
- this.getClass().getField(index.filename).set(this, reader);
- } catch (RuntimeException e) {
- throw new RuntimeException(e);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public IIndexReader getReader(final Index index) {
- try {
- return (IIndexReader) this.getClass().getField(index.filename).get(this);
- } catch (RuntimeException e) {
- throw new RuntimeException(e);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public void init(final String prefix) throws IOException {
- new Visitor() {
-
- @Override void visit(Index index, IIndexReader reader) throws IOException {
- if (reader != null) return;
-
- try {
- File indexFile = index.getFile(prefix);
- if (indexFile.exists()) {
- Constructor<?> constructor = index.impl.getConstructor(new Class[] { File.class });
- reader = (IIndexReader) constructor.newInstance(new Object[] { indexFile });
- setReader(index, reader);
- }
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- } catch (InstantiationException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
- Throwable cause = e.getCause();
- String msg = MessageFormat.format("{0}: {1}", //$NON-NLS-1$
- cause.getClass().getName(), cause.getMessage());
- throw new IOException(msg, cause);
- } catch (RuntimeException e) {
- // re-wrap runtime exceptions caught during index processing
- // into IOExceptions -> trigger reparsing of hprof dump
- throw new IOException(e);
- }
- }
- }.doIt();
- }
-
- public IIndexReader.IOne2ManyIndex inbound() {
- return inbound;
- }
-
- public IIndexReader.IOne2ManyIndex outbound() {
- return outbound;
- }
-
- public IIndexReader.IOne2OneIndex o2class() {
- return o2c;
- }
-
- public IIndexReader.IOne2ManyObjectsIndex c2objects() {
- return inbound;
- }
-
- public IIndexReader.IOne2LongIndex o2address() {
- return idx;
- }
-
- public IIndexReader.IOne2OneIndex a2size() {
- return a2s;
- }
-
- public IIndexReader.IOne2ManyIndex dominated() {
- return domOut;
- }
-
- public IIndexReader.IOne2LongIndex o2retained() {
- return o2ret;
- }
-
- public IIndexReader.IOne2OneIndex dominator() {
- return domIn;
- }
-
- public void close() throws IOException {
- new Visitor() {
-
- @Override void visit(Index index, IIndexReader reader) throws IOException {
- if (reader == null) return;
-
- reader.close();
- setReader(index, null);
- }
- }.doIt();
- }
-
- public void delete() throws IOException {
- new Visitor() {
-
- @Override void visit(Index index, IIndexReader reader) throws IOException {
- if (reader == null) return;
-
- reader.close();
- reader.delete();
- setReader(index, null);
- }
- }.doIt();
- }
-
- private abstract class Visitor {
- abstract void visit(Index index, IIndexReader reader) throws IOException;
-
- void doIt() throws IOException {
- try {
- for (Index index : Index.values()) {
- IIndexReader reader = getReader(index);
- visit(index, reader);
- }
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/index/IndexReader.java b/src/main/java/org/eclipse/mat/parser/index/IndexReader.java
deleted file mode 100644
index ae7cd59..0000000
--- a/src/main/java/org/eclipse/mat/parser/index/IndexReader.java
+++ /dev/null
@@ -1,477 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.index;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.io.Serializable;
-import java.lang.ref.SoftReference;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.ArrayIntCompressed;
-import org.eclipse.mat.collect.ArrayLongCompressed;
-import org.eclipse.mat.collect.HashMapIntObject;
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.parser.io.SimpleBufferedRandomAccessInputStream;
-
-public abstract class IndexReader {
- public static final boolean DEBUG = false;
-
- public static class IntIndexReader extends IndexWriter.IntIndex<SoftReference<ArrayIntCompressed>>
- implements IIndexReader.IOne2OneIndex {
- public Object LOCK = new Object();
-
- File indexFile;
- public SimpleBufferedRandomAccessInputStream in;
- long[] pageStart;
-
- public IntIndexReader(File indexFile,
- IndexWriter.Pages<SoftReference<ArrayIntCompressed>> pages, int size, int pageSize,
- long[] pageStart) {
- this.size = size;
- this.pageSize = pageSize;
- this.pages = pages;
-
- this.indexFile = indexFile;
- this.pageStart = pageStart;
-
- if (indexFile != null) open();
- }
-
- public IntIndexReader(File indexFile) throws IOException {
- this(new SimpleBufferedRandomAccessInputStream(new RandomAccessFile(indexFile, "r")), 0,
- indexFile.length());//$NON-NLS-1$
- this.indexFile = indexFile;
- }
-
- public IntIndexReader(SimpleBufferedRandomAccessInputStream in, long start, long length)
- throws IOException {
- this.in = in;
- this.in.seek(start + length - 8);
-
- int pageSize = this.in.readInt();
- int size = this.in.readInt();
-
- init(size, pageSize);
-
- int pages = (size / pageSize) + (size % pageSize > 0 ? 2 : 1);
-
- pageStart = new long[pages];
-
- this.in.seek(start + length - 8 - (pageStart.length * 8));
- this.in.readLongArray(pageStart);
- }
-
- private synchronized void open() {
- try {
- if (in != null) return;
-
- if (indexFile == null) {
- throw new IOException(Messages.IndexReader_Error_IndexIsEmbedded.pattern);
- }
-
- in = new SimpleBufferedRandomAccessInputStream(
- new RandomAccessFile(this.indexFile, "r"));//$NON-NLS-1$
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public synchronized void close() {
- unload();
-
- if (in != null) {
- try {
- in.close();
- } catch (IOException ignore) {
- // $JL-EXC$
- } finally {
- in = null;
- }
- }
- }
-
- @Override protected ArrayIntCompressed getPage(int page) {
- SoftReference<ArrayIntCompressed> ref = pages.get(page);
- ArrayIntCompressed array = ref == null ? null : ref.get();
- if (array == null) {
- synchronized (LOCK) {
- ref = pages.get(page);
- array = ref == null ? null : ref.get();
-
- if (array == null) {
- try {
- byte[] buffer = null;
-
- this.in.seek(pageStart[page]);
-
- buffer = new byte[(int) (pageStart[page + 1] - pageStart[page])];
- if (this.in.read(buffer) != buffer.length) throw new IOException();
-
- array = new ArrayIntCompressed(buffer);
-
- synchronized (pages) {
- pages.put(page, new SoftReference<ArrayIntCompressed>(array));
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- }
- }
- return array;
- }
-
- public void delete() {
- close();
-
- if (indexFile != null) indexFile.delete();
- }
- }
-
- /* package */static class IntIndex1NReader implements IIndexReader.IOne2ManyIndex {
- File indexFile;
- SimpleBufferedRandomAccessInputStream in;
- IntIndexReader header;
- IntIndexReader body;
-
- public IntIndex1NReader(File indexFile) throws IOException {
- try {
- this.indexFile = indexFile;
-
- open();
-
- long indexLength = indexFile.length();
- in.seek(indexLength - 8);
- long divider = in.readLong();
-
- this.header = new IntIndexReader(in, divider, indexLength - divider - 8);
- this.body = new IntIndexReader(in, 0, divider);
-
- this.body.LOCK = this.header.LOCK;
- } catch (RuntimeException e) {
- close();
- throw e;
- }
- }
-
- public IntIndex1NReader(File indexFile, IIndexReader.IOne2OneIndex header,
- IIndexReader.IOne2OneIndex body) {
- this.indexFile = indexFile;
- this.header = ((IntIndexReader) header);
- this.body = ((IntIndexReader) body);
-
- this.body.LOCK = this.header.LOCK;
-
- open();
- }
-
- public int[] get(int index) {
- int p = header.get(index);
-
- int length = body.get(p);
-
- return body.getNext(p + 1, length);
- }
-
- protected synchronized void open() {
- try {
- if (in == null) {
-
- in = new SimpleBufferedRandomAccessInputStream(
- new RandomAccessFile(this.indexFile, "r"));//$NON-NLS-1$
-
- if (this.header != null) this.header.in = in;
-
- if (this.body != null) this.body.in = in;
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public synchronized void close() {
- header.unload();
- body.unload();
-
- if (in != null) {
- try {
- in.close();
- } catch (IOException ignore) {
- // $JL-EXC$
- } finally {
- in = null;
- if (this.header != null) this.header.in = null;
- if (this.body != null) this.body.in = null;
- }
- }
- }
-
- public void unload() throws IOException {
- header.unload();
- body.unload();
- }
-
- public int size() {
- return header.size();
- }
-
- public void delete() {
- close();
-
- if (indexFile != null) indexFile.delete();
- }
- }
-
- public static class IntIndex1NSortedReader extends IntIndex1NReader {
- public IntIndex1NSortedReader(File indexFile) throws IOException {
- super(indexFile);
- }
-
- /**
- * @throws IOException
- */
- public IntIndex1NSortedReader(File indexFile, IOne2OneIndex header, IOne2OneIndex body)
- throws IOException {
- super(indexFile, header, body);
- }
-
- public int[] get(int index) {
- int p[] = null;
-
- if (index + 1 < header.size()) {
- p = header.getNext(index++, 2);
- if (p[0] == 0) return new int[0];
-
- for (index++; p[1] < p[0] && index < header.size(); index++)
- p[1] = header.get(index);
-
- if (p[1] < p[0]) p[1] = body.size() + 1;
- } else {
- p = new int[] { header.get(index), 0 };
- if (p[0] == 0) return new int[0];
- p[1] = body.size() + 1;
- }
-
- return body.getNext(p[0] - 1, p[1] - p[0]);
- }
- }
-
- static class InboundReader extends IntIndex1NSortedReader
- implements IIndexReader.IOne2ManyObjectsIndex {
- public InboundReader(File indexFile) throws IOException {
- super(indexFile);
- }
-
- public InboundReader(File indexFile, IOne2OneIndex header, IOne2OneIndex body)
- throws IOException {
- super(indexFile, header, body);
- }
-
- public int[] getObjectsOf(Serializable key) throws SnapshotException, IOException {
- if (key == null) return new int[0];
-
- int[] pos = (int[]) key;
-
- synchronized (this) {
- return body.getNext(pos[0], pos[1]);
- }
- }
- }
-
- public static class LongIndexReader extends IndexWriter.LongIndex
- implements IIndexReader.IOne2LongIndex {
- Object LOCK = new Object();
-
- File indexFile;
- SimpleBufferedRandomAccessInputStream in;
- long[] pageStart;
-
- public LongIndexReader(File indexFile, HashMapIntObject<Object> pages, int size, int pageSize,
- long[] pageStart) throws IOException {
- this.size = size;
- this.pageSize = pageSize;
- this.pages = pages;
-
- this.indexFile = indexFile;
- this.pageStart = pageStart;
-
- open();
- }
-
- public LongIndexReader(File indexFile) throws IOException {
- this(new SimpleBufferedRandomAccessInputStream(new RandomAccessFile(indexFile, "r")), 0,
- indexFile.length());//$NON-NLS-1$
- this.indexFile = indexFile;
-
- open();
- }
-
- protected LongIndexReader(SimpleBufferedRandomAccessInputStream in, long start, long length)
- throws IOException {
- this.in = in;
- this.in.seek(start + length - 8);
-
- int pageSize = this.in.readInt();
- int size = this.in.readInt();
-
- init(size, pageSize);
-
- int pages = (size / pageSize) + (size % pageSize > 0 ? 2 : 1);
-
- pageStart = new long[pages];
-
- this.in.seek(start + length - 8 - (pageStart.length * 8));
- this.in.readLongArray(pageStart);
- }
-
- private synchronized void open() throws IOException {
- if (in != null) return;
-
- if (indexFile == null) {
- throw new IOException(Messages.IndexReader_Error_IndexIsEmbedded.pattern);
- }
-
- in = new SimpleBufferedRandomAccessInputStream(
- new RandomAccessFile(this.indexFile, "r"));//$NON-NLS-1$
- }
-
- public synchronized void close() {
- unload();
-
- if (in != null) {
- try {
- in.close();
- } catch (IOException ignore) {
- // $JL-EXC$
- } finally {
- in = null;
- }
- }
- }
-
- @SuppressWarnings("unchecked") @Override protected ArrayLongCompressed getPage(int page) {
- SoftReference<ArrayLongCompressed> ref = (SoftReference<ArrayLongCompressed>) pages.get(page);
- ArrayLongCompressed array = ref == null ? null : ref.get();
- if (array == null) {
- synchronized (LOCK) {
- ref = (SoftReference<ArrayLongCompressed>) pages.get(page);
- array = ref == null ? null : ref.get();
-
- if (array == null) {
- try {
- byte[] buffer = null;
-
- this.in.seek(pageStart[page]);
-
- buffer = new byte[(int) (pageStart[page + 1] - pageStart[page])];
- if (this.in.read(buffer) != buffer.length) throw new IOException();
-
- array = new ArrayLongCompressed(buffer);
-
- synchronized (pages) {
- pages.put(page, new SoftReference<ArrayLongCompressed>(array));
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- }
- }
- return array;
- }
-
- public void delete() {
- close();
-
- if (indexFile != null) indexFile.delete();
- }
- }
-
- public static class LongIndex1NReader implements IIndexReader {
- File indexFile;
- SimpleBufferedRandomAccessInputStream in;
- IntIndexReader header;
- LongIndexReader body;
-
- public LongIndex1NReader(File indexFile) throws IOException {
- this.indexFile = indexFile;
-
- open();
-
- long indexLength = indexFile.length();
- in.seek(indexLength - 8);
- long divider = in.readLong();
-
- this.header = new IntIndexReader(in, divider, indexLength - divider - 8);
- this.body = new LongIndexReader(in, 0, divider);
-
- this.body.LOCK = this.header.LOCK;
- }
-
- public long[] get(int index) {
- int p = header.get(index);
-
- if (p == 0) return new long[0];
-
- int length = (int) body.get(p - 1);
-
- return body.getNext(p, length);
- }
-
- protected synchronized void open() {
- try {
- if (in == null) {
-
- in = new SimpleBufferedRandomAccessInputStream(
- new RandomAccessFile(this.indexFile, "r"));//$NON-NLS-1$
-
- if (this.header != null) this.header.in = in;
-
- if (this.body != null) this.body.in = in;
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public synchronized void close() {
- unload();
-
- if (in != null) {
- try {
- in.close();
- } catch (IOException ignore) {
- // $JL-EXC$
- } finally {
- in = this.header.in = this.body.in = null;
- }
- }
- }
-
- public void unload() {
- header.unload();
- body.unload();
- }
-
- public int size() {
- return header.size();
- }
-
- public void delete() {
- close();
-
- if (indexFile != null) indexFile.delete();
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/index/IndexWriter.java b/src/main/java/org/eclipse/mat/parser/index/IndexWriter.java
deleted file mode 100644
index 26f405c..0000000
--- a/src/main/java/org/eclipse/mat/parser/index/IndexWriter.java
+++ /dev/null
@@ -1,1314 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.index;
-
-import java.io.BufferedOutputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.ref.SoftReference;
-import java.util.Arrays;
-import java.util.NoSuchElementException;
-import org.eclipse.mat.collect.ArrayInt;
-import org.eclipse.mat.collect.ArrayIntCompressed;
-import org.eclipse.mat.collect.ArrayLong;
-import org.eclipse.mat.collect.ArrayLongCompressed;
-import org.eclipse.mat.collect.ArrayUtils;
-import org.eclipse.mat.collect.BitField;
-import org.eclipse.mat.collect.HashMapIntLong;
-import org.eclipse.mat.collect.HashMapIntObject;
-import org.eclipse.mat.collect.IteratorInt;
-import org.eclipse.mat.collect.IteratorLong;
-import org.eclipse.mat.collect.SetInt;
-import org.eclipse.mat.parser.index.IIndexReader.IOne2LongIndex;
-import org.eclipse.mat.parser.index.IIndexReader.IOne2OneIndex;
-import org.eclipse.mat.parser.io.BitInputStream;
-import org.eclipse.mat.parser.io.BitOutputStream;
-import org.eclipse.mat.util.IProgressListener;
-
-public abstract class IndexWriter {
- public static final int PAGE_SIZE_INT = 1000000;
- public static final int PAGE_SIZE_LONG = 500000;
-
- public interface KeyWriter {
- public void storeKey(int index, Serializable key);
- }
-
- // //////////////////////////////////////////////////////////////
- // integer based indices
- // //////////////////////////////////////////////////////////////
-
- public static class Identifier implements IIndexReader.IOne2LongIndex {
- long[] identifiers;
- int size;
-
- public void add(long id) {
- if (identifiers == null) {
- identifiers = new long[10000];
- size = 0;
- }
-
- if (size + 1 > identifiers.length) {
- int newCapacity = (identifiers.length * 3) / 2 + 1;
- if (newCapacity < size + 1) newCapacity = size + 1;
- identifiers = copyOf(identifiers, newCapacity);
- }
-
- identifiers[size++] = id;
- }
-
- public void sort() {
- Arrays.sort(identifiers, 0, size);
- }
-
- public int size() {
- return size;
- }
-
- public long get(int index) {
- if (index < 0 || index >= size) throw new IndexOutOfBoundsException();
-
- return identifiers[index];
- }
-
- public int reverse(long val) {
- int a, c;
- for (a = 0, c = size; a < c; ) {
- // Avoid overflow problems by using unsigned divide by 2
- int b = (a + c) >>> 1;
- long probeVal = get(b);
- if (val < probeVal) {
- c = b;
- } else if (probeVal < val) {
- a = b + 1;
- } else {
- return b;
- }
- }
- // Negative index indicates not found (and where to insert)
- return -1 - a;
- }
-
- public IteratorLong iterator() {
- return new IteratorLong() {
-
- int index = 0;
-
- public boolean hasNext() {
- return index < size;
- }
-
- public long next() {
- return identifiers[index++];
- }
- };
- }
-
- public long[] getNext(int index, int length) {
- long answer[] = new long[length];
- for (int ii = 0; ii < length; ii++)
- answer[ii] = identifiers[index + ii];
- return answer;
- }
-
- public void close() throws IOException {
- }
-
- public void delete() {
- identifiers = null;
- }
-
- public void unload() throws IOException {
- throw new UnsupportedOperationException();
- }
- }
-
- public static class IntIndexCollectorUncompressed {
- int[] dataElements;
-
- public IntIndexCollectorUncompressed(int size) {
- dataElements = new int[size];
- }
-
- public void set(int index, int value) {
- dataElements[index] = value;
- }
-
- public int get(int index) {
- return dataElements[index];
- }
-
- public IIndexReader.IOne2OneIndex writeTo(File indexFile) throws IOException {
- return new IntIndexStreamer().writeTo(indexFile, dataElements);
- }
- }
-
- static class Pages<V> {
- int size;
- Object[] elements;
-
- public Pages(int initialSize) {
- elements = new Object[initialSize];
- size = 0;
- }
-
- private void ensureCapacity(int minCapacity) {
- int oldCapacity = elements.length;
- if (minCapacity > oldCapacity) {
- int newCapacity = (oldCapacity * 3) / 2 + 1;
- if (newCapacity < minCapacity) newCapacity = minCapacity;
-
- Object[] copy = new Object[newCapacity];
- System.arraycopy(elements, 0, copy, 0, Math.min(elements.length, newCapacity));
- elements = copy;
- }
- }
-
- @SuppressWarnings("unchecked") public V get(int key) {
- return (key >= elements.length) ? null : (V) elements[key];
- }
-
- public void put(int key, V value) {
- ensureCapacity(key + 1);
- elements[key] = value;
- size = Math.max(size, key + 1);
- }
-
- public int size() {
- return size;
- }
- }
-
- abstract static class IntIndex<V> {
- int pageSize;
- int size;
- Pages<V> pages;
-
- protected IntIndex() {
- }
-
- protected IntIndex(int size) {
- init(size, PAGE_SIZE_INT);
- }
-
- protected void init(int size, int pageSize) {
- this.size = size;
- this.pageSize = pageSize;
- this.pages = new Pages<V>(size / pageSize + 1);
- }
-
- public int get(int index) {
- ArrayIntCompressed array = getPage(index / pageSize);
- return array.get(index % pageSize);
- }
-
- public int[] getNext(int index, int length) {
- int answer[] = new int[length];
- int page = index / pageSize;
- int pageIndex = index % pageSize;
-
- ArrayIntCompressed array = getPage(page);
- for (int ii = 0; ii < length; ii++) {
- answer[ii] = array.get(pageIndex++);
- if (pageIndex >= pageSize) {
- array = getPage(++page);
- pageIndex = 0;
- }
- }
-
- return answer;
- }
-
- @SuppressWarnings("null") public int[] getAll(int index[]) {
- int[] answer = new int[index.length];
-
- int page = -1;
- ArrayIntCompressed array = null;
-
- for (int ii = 0; ii < answer.length; ii++) {
- int p = index[ii] / pageSize;
- if (p != page) array = getPage(page = p);
-
- answer[ii] = array.get(index[ii] % pageSize);
- }
-
- return answer;
- }
-
- public void set(int index, int value) {
- ArrayIntCompressed array = getPage(index / pageSize);
- array.set(index % pageSize, value);
- }
-
- protected abstract ArrayIntCompressed getPage(int page);
-
- public synchronized void unload() {
- this.pages = new Pages<V>(size / pageSize + 1);
- }
-
- public int size() {
- return size;
- }
-
- public IteratorInt iterator() {
- return new IntIndexIterator(this);
- }
- }
-
- static class IntIndexIterator implements IteratorInt {
- IntIndex<?> intArray;
- int nextIndex = 0;
-
- public IntIndexIterator(IntIndex<?> intArray) {
- this.intArray = intArray;
- }
-
- public int next() {
- return intArray.get(nextIndex++);
- }
-
- public boolean hasNext() {
- return nextIndex < intArray.size();
- }
- }
-
- public static class IntIndexCollector extends IntIndex<ArrayIntCompressed>
- implements IOne2OneIndex {
- int mostSignificantBit;
-
- public IntIndexCollector(int size, int mostSignificantBit) {
- super(size);
- this.mostSignificantBit = mostSignificantBit;
- }
-
- @Override protected ArrayIntCompressed getPage(int page) {
- ArrayIntCompressed array = pages.get(page);
- if (array == null) {
- int ps = page < (size / pageSize) ? pageSize : size % pageSize;
- array = new ArrayIntCompressed(ps, 31 - mostSignificantBit, 0);
- pages.put(page, array);
- }
- return array;
- }
-
- public IIndexReader.IOne2OneIndex writeTo(File indexFile) throws IOException {
- // needed to re-compress
- return new IntIndexStreamer().writeTo(indexFile, this.iterator());
- }
-
- public IIndexReader.IOne2OneIndex writeTo(DataOutputStream out, long position)
- throws IOException {
- return new IntIndexStreamer().writeTo(out, position, this.iterator());
- }
-
- public void close() throws IOException {
- }
-
- public void delete() {
- pages = null;
- }
- }
-
- public static class IntIndexStreamer extends IntIndex<SoftReference<ArrayIntCompressed>> {
- DataOutputStream out;
- ArrayLong pageStart;
- int[] page;
- int left;
-
- public IIndexReader.IOne2OneIndex writeTo(File indexFile, IteratorInt iterator)
- throws IOException {
- DataOutputStream out =
- new DataOutputStream(new BufferedOutputStream(new FileOutputStream(indexFile)));
-
- openStream(out, 0);
- addAll(iterator);
- closeStream();
-
- out.close();
-
- return getReader(indexFile);
- }
-
- public IIndexReader.IOne2OneIndex writeTo(File indexFile, int[] array) throws IOException {
- DataOutputStream out =
- new DataOutputStream(new BufferedOutputStream(new FileOutputStream(indexFile)));
-
- openStream(out, 0);
- addAll(array);
- closeStream();
-
- out.close();
-
- return getReader(indexFile);
- }
-
- public IIndexReader.IOne2OneIndex writeTo(DataOutputStream out, long position,
- IteratorInt iterator) throws IOException {
- openStream(out, position);
- addAll(iterator);
- closeStream();
-
- return getReader(null);
- }
-
- public IIndexReader.IOne2OneIndex writeTo(DataOutputStream out, long position, int[] array)
- throws IOException {
- openStream(out, position);
- addAll(array);
- closeStream();
-
- return getReader(null);
- }
-
- void openStream(DataOutputStream out, long position) {
- this.out = out;
-
- init(0, PAGE_SIZE_INT);
-
- this.page = new int[pageSize];
- this.pageStart = new ArrayLong();
- this.pageStart.add(position);
- this.left = page.length;
- }
-
- /**
- * @return total bytes written to index file
- */
- long closeStream() throws IOException {
- if (left < page.length) addPage();
-
- // write header information
- for (int jj = 0; jj < pageStart.size(); jj++)
- out.writeLong(pageStart.get(jj));
-
- out.writeInt(pageSize);
- out.writeInt(size);
-
- this.page = null;
-
- this.out = null;
-
- return this.pageStart.lastElement() + (8 * pageStart.size()) + 8
- - this.pageStart.firstElement();
- }
-
- IndexReader.IntIndexReader getReader(File indexFile) {
- return new IndexReader.IntIndexReader(indexFile, pages, size, pageSize, pageStart.toArray());
- }
-
- void addAll(IteratorInt iterator) throws IOException {
- while (iterator.hasNext()) add(iterator.next());
- }
-
- void add(int value) throws IOException {
- if (left == 0) addPage();
-
- page[page.length - left--] = value;
- size++;
- }
-
- void addAll(int[] values) throws IOException {
- addAll(values, 0, values.length);
- }
-
- void addAll(int[] values, int offset, int length) throws IOException {
- while (length > 0) {
- if (left == 0) addPage();
-
- int chunk = Math.min(left, length);
-
- System.arraycopy(values, offset, page, page.length - left, chunk);
- left -= chunk;
- size += chunk;
-
- length -= chunk;
- offset += chunk;
- }
- }
-
- private void addPage() throws IOException {
- ArrayIntCompressed array = new ArrayIntCompressed(page, 0, page.length - left);
-
- byte[] buffer = array.toByteArray();
- out.write(buffer);
- int written = buffer.length;
-
- pages.put(pages.size(), new SoftReference<ArrayIntCompressed>(array));
- pageStart.add(pageStart.lastElement() + written);
-
- left = page.length;
- }
-
- @Override protected ArrayIntCompressed getPage(int page) {
- throw new UnsupportedOperationException();
- }
- }
-
- public static class IntArray1NWriter {
- int[] header;
- File indexFile;
-
- DataOutputStream out;
- IntIndexStreamer body;
-
- public IntArray1NWriter(int size, File indexFile) throws IOException {
- this.header = new int[size];
- this.indexFile = indexFile;
-
- this.out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(indexFile)));
- this.body = new IntIndexStreamer();
- this.body.openStream(this.out, 0);
- }
-
- public void log(Identifier identifer, int index, ArrayLong references) throws IOException {
- // remove duplicates and convert to identifiers
- // keep pseudo reference as first one
-
- long pseudo = references.firstElement();
-
- references.sort();
-
- int[] objectIds = new int[references.size()];
- int length = 1;
-
- long current = 0, last = references.firstElement() - 1;
- for (int ii = 0; ii < objectIds.length; ii++) {
- current = references.get(ii);
- if (last != current) {
- int objectId = identifer.reverse(current);
-
- if (objectId >= 0) {
- int jj = (current == pseudo) ? 0 : length++;
- objectIds[jj] = objectId;
- }
- }
-
- last = current;
- }
-
- this.set(index, objectIds, 0, length);
- }
-
- /**
- * must not contain duplicates!
- */
- public void log(int index, ArrayInt references) throws IOException {
- this.set(index, references.toArray(), 0, references.size());
- }
-
- public void log(int index, int[] values) throws IOException {
- this.set(index, values, 0, values.length);
- }
-
- protected void set(int index, int[] values, int offset, int length) throws IOException {
- header[index] = body.size();
-
- body.add(length);
-
- body.addAll(values, offset, length);
- }
-
- public IIndexReader.IOne2ManyIndex flush() throws IOException {
- long divider = body.closeStream();
-
- IIndexReader.IOne2OneIndex headerIndex = new IntIndexStreamer().writeTo(out, divider, header);
-
- out.writeLong(divider);
-
- out.close();
- out = null;
-
- return createReader(headerIndex, body.getReader(null));
- }
-
- /**
- * @throws IOException
- */
- protected IIndexReader.IOne2ManyIndex createReader(IIndexReader.IOne2OneIndex headerIndex,
- IIndexReader.IOne2OneIndex bodyIndex) throws IOException {
- return new IndexReader.IntIndex1NReader(this.indexFile, headerIndex, bodyIndex);
- }
-
- public void cancel() {
- try {
- if (out != null) {
- out.close();
- body = null;
- out = null;
- }
- } catch (IOException ignore) {
- } finally {
- if (indexFile.exists()) indexFile.delete();
- }
- }
-
- public File getIndexFile() {
- return indexFile;
- }
- }
-
- public static class IntArray1NSortedWriter extends IntArray1NWriter {
- public IntArray1NSortedWriter(int size, File indexFile) throws IOException {
- super(size, indexFile);
- }
-
- protected void set(int index, int[] values, int offset, int length) throws IOException {
- header[index] = body.size() + 1;
-
- body.addAll(values, offset, length);
- }
-
- protected IIndexReader.IOne2ManyIndex createReader(IIndexReader.IOne2OneIndex headerIndex,
- IIndexReader.IOne2OneIndex bodyIndex) throws IOException {
- return new IndexReader.IntIndex1NSortedReader(this.indexFile, headerIndex, bodyIndex);
- }
- }
-
- public static class InboundWriter {
- int size;
- File indexFile;
-
- int bitLength;
- int pageSize;
- BitOutputStream[] segments;
- int[] segmentSizes;
-
- /**
- * @throws IOException
- */
- public InboundWriter(int size, File indexFile) throws IOException {
- this.size = size;
- this.indexFile = indexFile;
-
- int requiredSegments = (size / 500000) + 1;
-
- int segments = 1;
- while (segments < requiredSegments) segments <<= 1;
-
- this.bitLength = mostSignificantBit(size) + 1;
- this.pageSize = (size / segments) + 1;
- this.segments = new BitOutputStream[segments];
- this.segmentSizes = new int[segments];
- }
-
- public void log(int objectIndex, int refIndex, boolean isPseudo) throws IOException {
- int segment = objectIndex / pageSize;
- if (segments[segment] == null) {
- File segmentFile =
- new File(this.indexFile.getAbsolutePath() + segment + ".log");//$NON-NLS-1$
- segments[segment] = new BitOutputStream(new FileOutputStream(segmentFile));
- }
-
- segments[segment].writeBit(isPseudo ? 1 : 0);
- segments[segment].writeInt(objectIndex, bitLength);
- segments[segment].writeInt(refIndex, bitLength);
-
- segmentSizes[segment]++;
- }
-
- public IIndexReader.IOne2ManyObjectsIndex flush(IProgressListener monitor, KeyWriter keyWriter)
- throws IOException {
- close();
-
- int[] header = new int[size];
-
- DataOutputStream index = new DataOutputStream(
- new BufferedOutputStream(new FileOutputStream(this.indexFile), 1024 * 256));
-
- BitInputStream segmentIn = null;
-
- try {
- IntIndexStreamer body = new IntIndexStreamer();
- body.openStream(index, 0);
-
- for (int segment = 0; segment < segments.length; segment++) {
- if (monitor.isCanceled()) throw new IProgressListener.OperationCanceledException();
-
- File segmentFile =
- new File(this.indexFile.getAbsolutePath() + segment + ".log");//$NON-NLS-1$
- if (!segmentFile.exists()) continue;
-
- // read & sort payload
- segmentIn = new BitInputStream(new FileInputStream(segmentFile));
-
- int objIndex[] = new int[segmentSizes[segment]];
- int refIndex[] = new int[segmentSizes[segment]];
-
- for (int ii = 0; ii < segmentSizes[segment]; ii++) {
-
- boolean isPseudo = segmentIn.readBit() == 1;
-
- objIndex[ii] = segmentIn.readInt(bitLength);
- refIndex[ii] = segmentIn.readInt(bitLength);
-
- if (isPseudo) refIndex[ii] = -1 - refIndex[ii]; // 0 is a valid!
- }
-
- segmentIn.close();
- segmentIn = null;
-
- if (monitor.isCanceled()) throw new IProgressListener.OperationCanceledException();
-
- // delete segment log
- segmentFile.delete();
- segmentFile = null;
-
- processSegment(monitor, keyWriter, header, body, objIndex, refIndex);
- }
-
- // write header
- long divider = body.closeStream();
- IIndexReader.IOne2OneIndex headerIndex =
- new IntIndexStreamer().writeTo(index, divider, header);
-
- index.writeLong(divider);
-
- index.flush();
- index.close();
-
- index = null;
-
- // return index reader
- return new IndexReader.InboundReader(this.indexFile, headerIndex, body.getReader(null));
- } finally {
- try {
- if (index != null) index.close();
- } catch (IOException ignore) {
- }
-
- try {
- if (segmentIn != null) segmentIn.close();
- } catch (IOException ignore) {
- }
-
- if (monitor.isCanceled()) cancel();
- }
- }
-
- private void processSegment(IProgressListener monitor, KeyWriter keyWriter, int[] header,
- IntIndexStreamer body, int[] objIndex, int[] refIndex) throws IOException {
- // sort (only by objIndex though)
- ArrayUtils.sort(objIndex, refIndex);
-
- // write index body
- int start = 0;
- int previous = -1;
-
- for (int ii = 0; ii <= objIndex.length; ii++) {
- if (ii == 0) {
- start = ii;
- previous = objIndex[ii];
- } else if (ii == objIndex.length || previous != objIndex[ii]) {
- if (monitor.isCanceled()) throw new IProgressListener.OperationCanceledException();
-
- header[previous] = body.size() + 1;
-
- processObject(keyWriter, header, body, previous, refIndex, start, ii);
-
- if (ii < objIndex.length) {
- previous = objIndex[ii];
- start = ii;
- }
- }
- }
- }
-
- private void processObject(KeyWriter keyWriter, int[] header, IntIndexStreamer body,
- int objectId, int[] refIndex, int fromIndex, int toIndex) throws IOException {
- Arrays.sort(refIndex, fromIndex, toIndex);
-
- int endPseudo = fromIndex;
-
- if ((toIndex - fromIndex) > 100000) {
- BitField duplicates = new BitField(size);
-
- int jj = fromIndex;
-
- for (; jj < toIndex; jj++) // pseudo references
- {
- if (refIndex[jj] >= 0) break;
-
- endPseudo++;
- refIndex[jj] = -refIndex[jj] - 1;
-
- if (!duplicates.get(refIndex[jj])) {
- body.add(refIndex[jj]);
- duplicates.set(refIndex[jj]);
- }
- }
-
- for (; jj < toIndex; jj++) // other references
- {
- if ((jj == fromIndex || refIndex[jj - 1] != refIndex[jj]) && !duplicates.get(
- refIndex[jj])) {
- body.add(refIndex[jj]);
- }
- }
- } else {
- SetInt duplicates = new SetInt(toIndex - fromIndex);
-
- int jj = fromIndex;
-
- for (; jj < toIndex; jj++) // pseudo references
- {
- if (refIndex[jj] >= 0) break;
-
- endPseudo++;
- refIndex[jj] = -refIndex[jj] - 1;
-
- if (duplicates.add(refIndex[jj])) body.add(refIndex[jj]);
- }
-
- for (; jj < toIndex; jj++) // other references
- {
- if ((jj == fromIndex || refIndex[jj - 1] != refIndex[jj]) && !duplicates.contains(
- refIndex[jj])) {
- body.add(refIndex[jj]);
- }
- }
- }
-
- if (endPseudo > fromIndex) {
- keyWriter.storeKey(objectId, new int[] { header[objectId] - 1, endPseudo - fromIndex });
- }
- }
-
- public synchronized void cancel() {
- try {
- close();
-
- if (segments != null) {
- for (int ii = 0; ii < segments.length; ii++) {
- new File(this.indexFile.getAbsolutePath() + ii + ".log").delete();//$NON-NLS-1$
- }
- }
- } catch (IOException ignore) {
- } finally {
- indexFile.delete();
- }
- }
-
- public synchronized void close() throws IOException {
- if (segments != null) {
- for (int ii = 0; ii < segments.length; ii++) {
- if (segments[ii] != null) {
- segments[ii].flush();
- segments[ii].close();
- segments[ii] = null;
- }
- }
- }
- }
-
- public File getIndexFile() {
- return indexFile;
- }
- }
-
- public static class IntArray1NUncompressedCollector {
- int[][] elements;
- File indexFile;
-
- /**
- * @throws IOException
- */
- public IntArray1NUncompressedCollector(int size, File indexFile) throws IOException {
- this.elements = new int[size][];
- this.indexFile = indexFile;
- }
-
- public void log(int classId, int methodId) {
- if (elements[classId] == null) {
- elements[classId] = new int[] { methodId };
- } else {
- int[] newChildren = new int[elements[classId].length + 1];
- System.arraycopy(elements[classId], 0, newChildren, 0, elements[classId].length);
- newChildren[elements[classId].length] = methodId;
- elements[classId] = newChildren;
- }
- }
-
- public File getIndexFile() {
- return indexFile;
- }
-
- public IIndexReader.IOne2ManyIndex flush() throws IOException {
- IntArray1NSortedWriter writer = new IntArray1NSortedWriter(elements.length, indexFile);
- for (int ii = 0; ii < elements.length; ii++) {
- if (elements[ii] != null) writer.log(ii, elements[ii]);
- }
- return writer.flush();
- }
- }
-
- // //////////////////////////////////////////////////////////////
- // long based indices
- // //////////////////////////////////////////////////////////////
-
- public static class LongIndexCollectorUncompressed {
- long[] dataElements;
-
- public LongIndexCollectorUncompressed(int size) {
- dataElements = new long[size];
- }
-
- public void set(int index, long value) {
- dataElements[index] = value;
- }
-
- public long get(int index) {
- return dataElements[index];
- }
-
- public IIndexReader.IOne2LongIndex writeTo(File indexFile) throws IOException {
- return new LongIndexStreamer().writeTo(indexFile, dataElements);
- }
- }
-
- abstract static class LongIndex {
- private static final int DEPTH = 10;
-
- int pageSize;
- int size;
- // pages are either IntArrayCompressed or
- // SoftReference<IntArrayCompressed>
- HashMapIntObject<Object> pages;
- HashMapIntLong binarySearchCache = new HashMapIntLong(1 << DEPTH);
-
- protected LongIndex() {
- }
-
- protected LongIndex(int size) {
- init(size, PAGE_SIZE_LONG);
- }
-
- protected void init(int size, int pageSize) {
- this.size = size;
- this.pageSize = pageSize;
- this.pages = new HashMapIntObject<Object>(size / pageSize + 1);
- }
-
- public long get(int index) {
- ArrayLongCompressed array = getPage(index / pageSize);
- return array.get(index % pageSize);
- }
-
- public long[] getNext(int index, int length) {
- long answer[] = new long[length];
- int page = index / pageSize;
- int pageIndex = index % pageSize;
-
- ArrayLongCompressed array = getPage(page);
- for (int ii = 0; ii < length; ii++) {
- answer[ii] = array.get(pageIndex++);
- if (pageIndex >= pageSize) {
- array = getPage(++page);
- pageIndex = 0;
- }
- }
-
- return answer;
- }
-
- @SuppressWarnings("null") public int reverse(long value) {
- int low = 0;
- int high = size - 1;
-
- int depth = 0;
- int page = -1;
- ArrayLongCompressed array = null;
-
- while (low <= high) {
- int mid = (low + high) >> 1;
-
- long midVal;
-
- if (depth++ < DEPTH) {
- try {
- midVal = binarySearchCache.get(mid);
- } catch (NoSuchElementException e) {
- int p = mid / pageSize;
- if (p != page) array = getPage(page = p);
-
- midVal = array.get(mid % pageSize);
-
- binarySearchCache.put(mid, midVal);
- }
- } else {
- int p = mid / pageSize;
- if (p != page) array = getPage(page = p);
-
- midVal = array.get(mid % pageSize);
- }
-
- if (midVal < value) {
- low = mid + 1;
- } else if (midVal > value) {
- high = mid - 1;
- } else {
- return mid; // key found
- }
- }
- return -(low + 1); // key not found.
- }
-
- public void set(int index, long value) {
- ArrayLongCompressed array = getPage(index / pageSize);
- array.set(index % pageSize, value);
- }
-
- protected abstract ArrayLongCompressed getPage(int page);
-
- public synchronized void unload() {
- pages = new HashMapIntObject<Object>(size / pageSize + 1);
- binarySearchCache = new HashMapIntLong(1 << DEPTH);
- }
-
- public int size() {
- return size;
- }
-
- public IteratorLong iterator() {
- return new LongIndexIterator(this);
- }
- }
-
- static class LongIndexIterator implements IteratorLong {
- LongIndex longArray;
- int nextIndex = 0;
-
- public LongIndexIterator(LongIndex longArray) {
- this.longArray = longArray;
- }
-
- public long next() {
- return longArray.get(nextIndex++);
- }
-
- public boolean hasNext() {
- return nextIndex < longArray.size();
- }
- }
-
- public static class LongIndexCollector extends LongIndex {
- int mostSignificantBit;
-
- public LongIndexCollector(int size, int mostSignificantBit) {
- super(size);
- this.mostSignificantBit = mostSignificantBit;
- }
-
- @Override protected ArrayLongCompressed getPage(int page) {
- ArrayLongCompressed array = (ArrayLongCompressed) pages.get(page);
- if (array == null) {
- int ps = page < (size / pageSize) ? pageSize : size % pageSize;
- array = new ArrayLongCompressed(ps, 63 - mostSignificantBit, 0);
- pages.put(page, array);
- }
- return array;
- }
-
- public IIndexReader.IOne2LongIndex writeTo(File indexFile) throws IOException {
- // needed to re-compress
- return new LongIndexStreamer().writeTo(indexFile, this.size, this.pages, this.pageSize);
- }
- }
-
- public static class LongIndexStreamer extends LongIndex {
- DataOutputStream out;
- ArrayLong pageStart;
- long[] page;
- int left;
-
- public LongIndexStreamer() {
- }
-
- public LongIndexStreamer(File indexFile) throws IOException {
- DataOutputStream out =
- new DataOutputStream(new BufferedOutputStream(new FileOutputStream(indexFile)));
- openStream(out, 0);
- }
-
- public void close() throws IOException {
- DataOutputStream out = this.out;
- closeStream();
- out.close();
- }
-
- public IOne2LongIndex writeTo(File indexFile, int size, HashMapIntObject<Object> pages,
- int pageSize) throws IOException {
- DataOutputStream out =
- new DataOutputStream(new BufferedOutputStream(new FileOutputStream(indexFile)));
-
- openStream(out, 0);
-
- int noOfPages = size / pageSize + (size % pageSize > 0 ? 1 : 0);
- for (int ii = 0; ii < noOfPages; ii++) {
- ArrayLongCompressed a = (ArrayLongCompressed) pages.get(ii);
- int len = (ii + 1) < noOfPages ? pageSize : (size % pageSize);
-
- if (a == null) {
- addAll(new long[len]);
- } else {
- for (int jj = 0; jj < len; jj++) {
- add(a.get(jj));
- }
- }
- }
-
- closeStream();
- out.close();
-
- return getReader(indexFile);
- }
-
- public IOne2LongIndex writeTo(File indexFile, long[] array) throws IOException {
- DataOutputStream out =
- new DataOutputStream(new BufferedOutputStream(new FileOutputStream(indexFile)));
-
- openStream(out, 0);
- addAll(array);
- closeStream();
-
- out.close();
-
- return getReader(indexFile);
- }
-
- public IOne2LongIndex writeTo(File indexFile, IteratorLong iterator) throws IOException {
- FileOutputStream fos = new FileOutputStream(indexFile);
- try {
- DataOutputStream out = new DataOutputStream(new BufferedOutputStream(fos));
-
- openStream(out, 0);
- addAll(iterator);
- closeStream();
-
- out.flush();
-
- return getReader(indexFile);
- } finally {
- try {
- fos.close();
- } catch (IOException ignore) {
- }
- }
- }
-
- public IOne2LongIndex writeTo(File indexFile, ArrayLong array) throws IOException {
- DataOutputStream out =
- new DataOutputStream(new BufferedOutputStream(new FileOutputStream(indexFile)));
-
- openStream(out, 0);
- addAll(array);
- closeStream();
-
- out.close();
-
- return getReader(indexFile);
- }
-
- void openStream(DataOutputStream out, long position) {
- this.out = out;
-
- init(0, PAGE_SIZE_LONG);
-
- this.page = new long[pageSize];
- this.pageStart = new ArrayLong();
- this.pageStart.add(position);
- this.left = page.length;
- }
-
- /**
- * @return total bytes written to index file
- */
- long closeStream() throws IOException {
- if (left < page.length) addPage();
-
- // write header information
- for (int jj = 0; jj < pageStart.size(); jj++)
- out.writeLong(pageStart.get(jj));
-
- out.writeInt(pageSize);
- out.writeInt(size);
-
- this.page = null;
-
- this.out = null;
-
- return this.pageStart.lastElement() + (8 * pageStart.size()) + 8
- - this.pageStart.firstElement();
- }
-
- IndexReader.LongIndexReader getReader(File indexFile) throws IOException {
- return new IndexReader.LongIndexReader(indexFile, pages, size, pageSize, pageStart.toArray());
- }
-
- public void addAll(IteratorLong iterator) throws IOException {
- while (iterator.hasNext()) add(iterator.next());
- }
-
- public void addAll(ArrayLong array) throws IOException {
- for (IteratorLong e = array.iterator(); e.hasNext(); )
- add(e.next());
- }
-
- public void add(long value) throws IOException {
- if (left == 0) addPage();
-
- page[page.length - left--] = value;
- size++;
- }
-
- public void addAll(long[] values) throws IOException {
- addAll(values, 0, values.length);
- }
-
- public void addAll(long[] values, int offset, int length) throws IOException {
- while (length > 0) {
- if (left == 0) addPage();
-
- int chunk = Math.min(left, length);
-
- System.arraycopy(values, offset, page, page.length - left, chunk);
- left -= chunk;
- size += chunk;
-
- length -= chunk;
- offset += chunk;
- }
- }
-
- private void addPage() throws IOException {
- ArrayLongCompressed array = new ArrayLongCompressed(page, 0, page.length - left);
-
- byte[] buffer = array.toByteArray();
- out.write(buffer);
- int written = buffer.length;
-
- pages.put(pages.size(), new SoftReference<ArrayLongCompressed>(array));
- pageStart.add(pageStart.lastElement() + written);
-
- left = page.length;
- }
-
- @Override protected ArrayLongCompressed getPage(int page) {
- throw new UnsupportedOperationException();
- }
- }
-
- public static class LongArray1NWriter {
- int[] header;
- File indexFile;
-
- DataOutputStream out;
- LongIndexStreamer body;
-
- public LongArray1NWriter(int size, File indexFile) throws IOException {
- this.header = new int[size];
- this.indexFile = indexFile;
-
- this.out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(indexFile)));
- this.body = new LongIndexStreamer();
- this.body.openStream(this.out, 0);
- }
-
- public void log(int index, long[] values) throws IOException {
- this.set(index, values, 0, values.length);
- }
-
- protected void set(int index, long[] values, int offset, int length) throws IOException {
- header[index] = body.size() + 1;
-
- body.add(length);
-
- body.addAll(values, offset, length);
- }
-
- public void flush() throws IOException {
- long divider = body.closeStream();
-
- new IntIndexStreamer().writeTo(out, divider, header).close();
-
- out.writeLong(divider);
-
- out.close();
- out = null;
- }
-
- public void cancel() {
- try {
- if (out != null) {
- out.close();
- body = null;
- out = null;
- }
- } catch (IOException ignore) {
- } finally {
- if (indexFile.exists()) indexFile.delete();
- }
- }
-
- public File getIndexFile() {
- return indexFile;
- }
- }
-
- // //////////////////////////////////////////////////////////////
- // mama's little helpers
- // //////////////////////////////////////////////////////////////
-
- public static long[] copyOf(long[] original, int newLength) {
- long[] copy = new long[newLength];
- System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
- return copy;
- }
-
- public static int mostSignificantBit(int x) {
- int length = 0;
- if ((x & 0xffff0000) != 0) {
- length += 16;
- x >>= 16;
- }
- if ((x & 0xff00) != 0) {
- length += 8;
- x >>= 8;
- }
- if ((x & 0xf0) != 0) {
- length += 4;
- x >>= 4;
- }
- if ((x & 0xc) != 0) {
- length += 2;
- x >>= 2;
- }
- if ((x & 0x2) != 0) {
- length += 1;
- x >>= 1;
- }
- if ((x & 0x1) != 0) {
- length += 1;
- // x >>= 1;
- }
-
- return length - 1;
- }
-
- public static int mostSignificantBit(long x) {
- long lead = x >>> 32;
- return lead == 0x0 ? mostSignificantBit((int) x) : 32 + mostSignificantBit((int) lead);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/DominatorTree.java b/src/main/java/org/eclipse/mat/parser/internal/DominatorTree.java
deleted file mode 100644
index 32ab87b..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/DominatorTree.java
+++ /dev/null
@@ -1,530 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.NoSuchElementException;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.ArrayUtils;
-import org.eclipse.mat.collect.BitField;
-import org.eclipse.mat.collect.IteratorInt;
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.parser.index.IIndexReader;
-import org.eclipse.mat.parser.index.IndexManager;
-import org.eclipse.mat.parser.index.IndexManager.Index;
-import org.eclipse.mat.parser.index.IndexWriter;
-import org.eclipse.mat.parser.internal.util.IntStack;
-import org.eclipse.mat.util.IProgressListener;
-import org.eclipse.mat.util.SimpleMonitor;
-
-public class DominatorTree {
-
- public static void calculate(SnapshotImpl snapshot, IProgressListener listener)
- throws SnapshotException, IOException {
- new Calculator(snapshot, listener).compute();
- }
-
- static class Calculator {
- SnapshotImpl snapshot;
- SimpleMonitor monitor;
- IIndexReader.IOne2ManyIndex inboundIndex;
- IIndexReader.IOne2ManyIndex outboundIndex;
-
- int[] gcRootsArray;
- private BitField gcRootsSet;
-
- int[] bucket;
- private int r, n;
- private int[] dom;
- private int[] parent;
- private int[] anchestor;
- private int[] vertex;
- private int[] label;
- private int[] semi;
-
- private static int ROOT_VALUE = -1;
- private static int[] ROOT_VALUE_ARR = new int[] { ROOT_VALUE };
-
- public Calculator(SnapshotImpl snapshot, IProgressListener listener) throws SnapshotException {
-
- this.snapshot = snapshot;
- inboundIndex = snapshot.getIndexManager().inbound();
- outboundIndex = snapshot.getIndexManager().outbound();
- this.monitor =
- new SimpleMonitor(Messages.DominatorTree_CalculatingDominatorTree.pattern, listener,
- new int[] {
- 300, 300, 200, 200, 200
- });
- gcRootsArray = snapshot.getGCRoots();
- gcRootsSet = new BitField(snapshot.getSnapshotInfo().getNumberOfObjects());
- for (int id : gcRootsArray) {
- gcRootsSet.set(id);
- }
-
- IndexManager manager = this.snapshot.getIndexManager();
- try {
- manager.a2size().unload();
- manager.o2address().unload();
- manager.o2class().unload();
- } catch (IOException e) {
- throw new SnapshotException(e);
- }
-
- n = snapshot.getSnapshotInfo().getNumberOfObjects() + 1;
- r = 1;
-
- dom = new int[n + 1];
- parent = new int[n + 1];
- anchestor = new int[n + 1];
- vertex = new int[n + 1];
- label = new int[n + 1];
- semi = new int[n + 1];
- bucket = new int[n + 1];
-
- Arrays.fill(bucket, -1);
- }
-
- public void compute()
- throws IOException, SnapshotException, IProgressListener.OperationCanceledException {
- IProgressListener progressListener0 = this.monitor.nextMonitor();
- progressListener0.beginTask(Messages.DominatorTree_DominatorTreeCalculation, 3);
-
- n = 0;
- dfs(r);
-
- snapshot.getIndexManager().outbound().unload();
-
- IProgressListener progressListener = this.monitor.nextMonitor();
- progressListener.beginTask(Messages.DominatorTree_ComputingDominators.pattern, n / 1000);
-
- for (int i = n; i >= 2; i--) {
- int w = vertex[i];
- for (int v : getPredecessors(w)) {
- v += 2;
- if (v < 0) continue;
- int u = eval(v);
- if (semi[u] < semi[w]) {
- semi[w] = semi[u];
- }
- }
- // add w to bucket(vertex(semi(w)))
- // create the bucket if needed
- bucket[w] = bucket[vertex[semi[w]]]; // serves as next(w)
- bucket[vertex[semi[w]]] = w; // serves as
- // first(vertex[semi[w]])
- link(parent[w], w);
-
- int v = bucket[parent[w]];
- while (v != -1) {
- int u = eval(v);
- if (semi[u] < semi[v]) {
- dom[v] = u;
- } else {
- dom[v] = parent[w];
- }
- v = bucket[v]; // here bucket serves as next[]
- }
- bucket[parent[w]] = -1;
- // }
- if (i % 1000 == 0) {
- if (progressListener.isCanceled()) {
- throw new IProgressListener.OperationCanceledException();
- }
- progressListener.worked(1);
- }
- }
-
- for (int i = 2; i <= n; i++) {
- int w = vertex[i];
- if (dom[w] != vertex[semi[w]]) {
- dom[w] = dom[dom[w]];
- }
- }
- dom[r] = 0;
-
- progressListener.done();
-
- parent = anchestor = vertex = label = semi = bucket = null;
- snapshot.getIndexManager().inbound().unload();
-
- if (progressListener0.isCanceled()) throw new IProgressListener.OperationCanceledException();
-
- // pre-condition for index writing:
- // retainedSetIdx is still sorted by object id
- snapshot.getIndexManager()
- .setReader(IndexManager.Index.DOMINATOR, new IndexWriter.IntIndexStreamer().writeTo(
- IndexManager.Index.DOMINATOR.getFile(snapshot.getSnapshotInfo().getPrefix()),
- new IteratorInt() {
- int nextIndex = 2;
-
- public boolean hasNext() {
- return nextIndex < dom.length;
- }
-
- public int next() {
- return dom[nextIndex++];
- }
- }));
-
- int[] objectIds = new int[snapshot.getSnapshotInfo().getNumberOfObjects() + 2];
- for (int i = 0; i < objectIds.length; i++)
- objectIds[i] = i - 2;
-
- objectIds[0] = -2;
- objectIds[1] = ROOT_VALUE;
- progressListener0.worked(1);
-
- ArrayUtils.sort(dom, objectIds, 2, dom.length - 2);
- progressListener0.worked(1);
-
- FlatDominatorTree tree = new FlatDominatorTree(snapshot, dom, objectIds, ROOT_VALUE);
-
- if (progressListener0.isCanceled()) throw new IProgressListener.OperationCanceledException();
-
- writeIndexFiles(tree);
- progressListener0.done();
- }
-
- private void dfs(int root) throws UnsupportedOperationException {
- IProgressListener progressListener = this.monitor.nextMonitor();
- progressListener.beginTask(Messages.DominatorTree_DepthFirstSearch,
- snapshot.getSnapshotInfo().getNumberOfObjects() >> 16);
-
- // a stack for each parameter - stack code is inlined for
- // performance
- // currentElementStack - for v, successorsStack - for the successors
- // array,
- // currentSuccessorStack - for the index in the array
- int capacity = 2048; // capacity for the arrays
- int size = 0; // one size for all arrays
- int[] currentElementStack = new int[capacity];
- int[] currentSuccessorStack = new int[capacity];
- Object[] successorsStack = new Object[capacity];
-
- int v = root;
- int[] successors = gcRootsArray;
- int currentSuccessor = 0;
-
- // push the initial values
- currentElementStack[size] = root;
- successorsStack[size] = successors;
- currentSuccessorStack[size] = currentSuccessor;
- size++;
-
- while (size > 0) {
- v = currentElementStack[size - 1];
- successors = (int[]) successorsStack[size - 1];
- currentSuccessor = currentSuccessorStack[size - 1];
-
- if (semi[v] == 0) {
- n = n + 1;
- semi[v] = n;
- vertex[n] = v;
- label[v] = v;
- anchestor[v] = 0;
- }
-
- if (currentSuccessor < successors.length) {
- int w = successors[currentSuccessor++] + 2;
- currentSuccessorStack[size - 1] = currentSuccessor; // update
- // the top
- // value
-
- // push the next unvisited successor
- if (semi[w] == 0) {
- parent[w] = v;
- successors = outboundIndex.get(w - 2); // get the
- // successors of w
-
- /* start push() */
- // is expanding needed?
- if (size == capacity) {
- int newCapacity = capacity << 1;
- // resize currentElementStack
- int[] newArr = new int[newCapacity];
- System.arraycopy(currentElementStack, 0, newArr, 0, capacity);
- currentElementStack = newArr;
-
- // resize currentSuccessorStack
- newArr = new int[newCapacity];
- System.arraycopy(currentSuccessorStack, 0, newArr, 0, capacity);
- currentSuccessorStack = newArr;
-
- // resize successorsStack
- Object[] newSuccessorsArr = new Object[newCapacity];
- System.arraycopy(successorsStack, 0, newSuccessorsArr, 0, capacity);
- successorsStack = newSuccessorsArr;
-
- capacity = newCapacity;
- }
- currentElementStack[size] = w;
- successorsStack[size] = successors;
- currentSuccessorStack[size] = 0;
- size++;
- /* end push() */
-
- // report progress
- if ((n & 0xffff) == 0) {
- if (progressListener.isCanceled()) {
- throw new IProgressListener.OperationCanceledException();
- }
- progressListener.worked(1);
- }
- }
- } else {
- // this one acts as a pop() for all tree stacks
- size--;
- }
- }
-
- progressListener.done();
- }
-
- // gets retained set idx and returns the real indexes
- private int[] getPredecessors(int v) {
- v -= 2;
- // for the GC roots return the artificial root
- if (gcRootsSet.get(v)) {
- return ROOT_VALUE_ARR;
- } else {
- return inboundIndex.get(v);
- }
- }
-
- private void compress(int v) {
- IntStack stack = new IntStack();
- while (anchestor[anchestor[v]] != 0) // is ancestor[v] a root in
- // the
- // forest?
- {
- stack.push(v);
- v = anchestor[v];
- }
- while (stack.size() > 0) {
- v = stack.pop();
- if (semi[label[anchestor[v]]] < semi[label[v]]) {
- label[v] = label[anchestor[v]];
- }
- anchestor[v] = anchestor[anchestor[v]];
- }
- }
-
- private int eval(int v) {
- if (anchestor[v] == 0) {
- return v;
- } else {
- compress(v);
- return label[v];
- }
- }
-
- private void link(int v, int w) {
- anchestor[w] = v;
- }
-
- private void writeIndexFiles(FlatDominatorTree tree) throws IOException {
-
- IndexWriter.IntArray1NWriter writer = new IndexWriter.IntArray1NWriter(dom.length - 1,
- IndexManager.Index.DOMINATED.getFile(snapshot.getSnapshotInfo().getPrefix()));
-
- int numberOfObjects = snapshot.getSnapshotInfo().getNumberOfObjects();
-
- IProgressListener progressListener = this.monitor.nextMonitor();
- progressListener.beginTask(Messages.DominatorTree_CreateDominatorsIndexFile,
- numberOfObjects / 1000);
-
- for (int i = -1; i < numberOfObjects; i++) {
- int[] successors = tree.getSuccessorsArr(i);
- tree.sortByTotalSize(successors);
- writer.log(i + 1, successors);
-
- if (i % 1000 == 0) {
- if (progressListener.isCanceled()) {
- throw new IProgressListener.OperationCanceledException();
- }
- progressListener.worked(1);
- }
- }
-
- snapshot.getIndexManager().setReader(IndexManager.Index.DOMINATED, writer.flush());
-
- progressListener.done();
- }
-
- public class FlatDominatorTree {
- private static final int TEMP_ARR_LENGTH = 1000000;
-
- int[] dom;
- int[] elements;
- long[] ts;
- SnapshotImpl dump;
-
- // temp arrays to pass for the radix sort
- long[] tempLongArray = new long[TEMP_ARR_LENGTH];
- int[] tempIntArray = new int[TEMP_ARR_LENGTH];
-
- FlatDominatorTree(SnapshotImpl dump, int[] dom, int[] elements, int root)
- throws SnapshotException, IOException {
- this.dump = dump;
- this.dom = dom;
- this.elements = elements;
- this.ts = new long[dom.length];
- calculateTotalSizesIterative(root);
- }
-
- public SuccessorsEnum getSuccessorsEnum(int i) {
- return new SuccessorsEnum(i);
- }
-
- public int[] getSuccessorsArr(int parentId) {
- parentId += 2;
-
- // find the first child
- int j = Arrays.binarySearch(dom, parentId);
- if (j < 0) return new int[0];
-
- int i = j;
- while ((i > 1) && (dom[i - 1] == parentId)) i--;
-
- // find length
- while (j < dom.length && dom[j] == parentId) j++;
-
- int length = j - i;
- int[] result = new int[length];
- System.arraycopy(elements, i, result, 0, length);
-
- return result;
- }
-
- public void sortByTotalSize(int[] objectIds) {
- int length = objectIds.length;
-
- // collect the total sizes of the objects
- long[] totalSizes = new long[length];
- for (int i = 0; i < length; i++) {
- totalSizes[i] = ts[objectIds[i] + 2];
- }
-
- // sort both arrays according to the total sizes
- if (totalSizes.length > 1) {
- if (totalSizes.length > TEMP_ARR_LENGTH) {
- ArrayUtils.sortDesc(totalSizes, objectIds);
- } else {
- ArrayUtils.sortDesc(totalSizes, objectIds, tempLongArray, tempIntArray);
- }
- }
- }
-
- class SuccessorsEnum {
- int parent;
- int nextIndex;
-
- SuccessorsEnum(int parent) {
- this.parent = parent;
- nextIndex = findFirstChildIndex(parent + 2);
- }
-
- public boolean hasMoreElements() {
- return nextIndex > 0;
- }
-
- public int nextElement() {
- if (nextIndex < 0) throw new NoSuchElementException();
- int res = elements[nextIndex++];
-
- if (nextIndex >= dom.length || dom[nextIndex] != parent + 2) nextIndex = -1;
-
- return res;
- }
-
- int findFirstChildIndex(int el) {
- int i = Arrays.binarySearch(dom, el);
- while ((i > 1) && (dom[i - 1] == el)) i--;
- return i;
- }
- }
-
- public void calculateTotalSizesIterative(int e) throws SnapshotException, IOException {
- IndexWriter.LongIndexCollector retained =
- new IndexWriter.LongIndexCollector(dump.getSnapshotInfo().getNumberOfObjects(),
- IndexWriter.mostSignificantBit(dump.getSnapshotInfo().getUsedHeapSize()));
-
- int capacity = 2048;
- int size = 0;
- int[] stack = new int[capacity];
- SuccessorsEnum[] succStack = new SuccessorsEnum[capacity];
-
- int currentEntry = e;
- SuccessorsEnum currentSucc = getSuccessorsEnum(currentEntry);
- stack[size] = currentEntry;
- succStack[size] = currentSucc;
- size++;
-
- IProgressListener progressListener = Calculator.this.monitor.nextMonitor();
- progressListener.beginTask(Messages.DominatorTree_CalculateRetainedSizes,
- dump.getSnapshotInfo().getNumberOfObjects() / 1000);
- int counter = 0;
-
- while (size > 0) {
- currentEntry = stack[size - 1];
- currentSucc = succStack[size - 1];
-
- if (currentSucc.hasMoreElements()) {
- int nextChild = currentSucc.nextElement();
- currentSucc = getSuccessorsEnum(nextChild);
-
- ts[nextChild + 2] = nextChild < 0 ? 0 : snapshot.getHeapSize(nextChild);
-
- if (size == capacity) {
- int newCapacity = capacity << 1;
- int[] newArr = new int[newCapacity];
- System.arraycopy(stack, 0, newArr, 0, capacity);
- stack = newArr;
-
- // resize successorsStack
- SuccessorsEnum[] newSuccessorsArr = new SuccessorsEnum[newCapacity];
- System.arraycopy(succStack, 0, newSuccessorsArr, 0, capacity);
- succStack = newSuccessorsArr;
- capacity = newCapacity;
- }
- stack[size] = nextChild;
- succStack[size] = currentSucc;
- size++;
- } else {
- size--;
-
- if (size > 0) ts[stack[size - 1] + 2] += ts[currentEntry + 2];
-
- if (currentEntry >= 0) {
- retained.set(currentEntry, ts[currentEntry + 2]);
- if (++counter % 1000 == 0) {
- if (progressListener.isCanceled()) {
- throw new IProgressListener.OperationCanceledException();
- }
- progressListener.worked(1);
- }
- }
- }
- }
-
- dump.getIndexManager()
- .setReader(Index.O2RETAINED, retained.writeTo(
- IndexManager.Index.O2RETAINED.getFile(dump.getSnapshotInfo().getPrefix())));
- retained = null;
-
- progressListener.done();
- }
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/GarbageCleaner.java b/src/main/java/org/eclipse/mat/parser/internal/GarbageCleaner.java
deleted file mode 100644
index 717326e..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/GarbageCleaner.java
+++ /dev/null
@@ -1,555 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.mat.collect.BitField;
-import org.eclipse.mat.collect.HashMapIntObject;
-import org.eclipse.mat.collect.IteratorInt;
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.parser.index.IIndexReader.IOne2LongIndex;
-import org.eclipse.mat.parser.index.IIndexReader.IOne2ManyIndex;
-import org.eclipse.mat.parser.index.IIndexReader.IOne2OneIndex;
-import org.eclipse.mat.parser.index.IndexManager;
-import org.eclipse.mat.parser.index.IndexManager.Index;
-import org.eclipse.mat.parser.index.IndexWriter;
-import org.eclipse.mat.parser.internal.snapshot.ObjectMarker;
-import org.eclipse.mat.parser.model.ClassImpl;
-import org.eclipse.mat.parser.model.XGCRootInfo;
-import org.eclipse.mat.util.IProgressListener;
-import org.eclipse.mat.util.IProgressListener.OperationCanceledException;
-import org.eclipse.mat.util.MessageUtil;
-import org.eclipse.mat.util.SilentProgressListener;
-
-/* package */class GarbageCleaner {
-
- public static int[] clean(final PreliminaryIndexImpl idx, final SnapshotImplBuilder builder,
- Map<String, String> arguments, IProgressListener listener) throws IOException {
- IndexManager idxManager = new IndexManager();
-
- try {
- listener.beginTask(Messages.GarbageCleaner_RemovingUnreachableObjects, 11);
- listener.subTask(Messages.GarbageCleaner_SearchingForUnreachableObjects.pattern);
-
- final int oldNoOfObjects = idx.identifiers.size();
-
- // determine reachable objects
- boolean[] reachable = new boolean[oldNoOfObjects];
- int newNoOfObjects = 0;
- int[] newRoots = idx.gcRoots.getAllKeys();
-
- IOne2LongIndex identifiers = idx.identifiers;
- IOne2ManyIndex preOutbound = idx.outbound;
- IOne2OneIndex object2classId = idx.object2classId;
- HashMapIntObject<ClassImpl> classesById = idx.classesById;
-
- /*
- * START - marking objects use ObjectMarker to mark the reachable
- * objects if more than 1 CPUs are available - use multithreading
- */
- int numProcessors = Runtime.getRuntime().availableProcessors();
- ObjectMarker marker =
- new ObjectMarker(newRoots, reachable, preOutbound, new SilentProgressListener(listener));
- if (numProcessors > 1) {
- try {
- marker.markMultiThreaded(numProcessors);
- } catch (InterruptedException e) {
- IOException ioe = new IOException(e.getMessage());
- ioe.initCause(e);
- throw ioe;
- }
-
- // find the number of new objects. It's not returned by marker
- for (boolean b : reachable)
- if (b) newNoOfObjects++;
- } else {
- try {
- newNoOfObjects = marker.markSingleThreaded();
- } catch (OperationCanceledException e) {
- // $JL-EXC$
- return null;
- }
- }
- marker = null;
- /* END - marking objects */
-
- // check if unreachable objects exist, then either mark as GC root
- // unreachable (keep objects) or store a histogram of unreachable
- // objects
- if (newNoOfObjects < oldNoOfObjects) {
- Object un = idx.getSnapshotInfo().getProperty("keep_unreachable_objects"); //$NON-NLS-1$
- if (un instanceof Integer) {
- int newRoot;
- newRoot = (Integer) un;
- markUnreachbleAsGCRoots(idx, reachable, newNoOfObjects, newRoot, listener);
- newNoOfObjects = oldNoOfObjects;
- }
- // else
- // {
- // createHistogramOfUnreachableObjects(idx, reachable);
- // }
- }
-
- if (listener.isCanceled()) throw new IProgressListener.OperationCanceledException();
- listener.worked(1); // 3
- listener.subTask(Messages.GarbageCleaner_ReIndexingObjects.pattern);
-
- // create re-index map
- final int[] map = new int[oldNoOfObjects];
- final long[] id2a = new long[newNoOfObjects];
-
- List<ClassImpl> classes2remove = new ArrayList<ClassImpl>();
-
- final IOne2OneIndex preA2size = idx.array2size;
-
- for (int ii = 0, jj = 0; ii < oldNoOfObjects; ii++) {
- if (reachable[ii]) {
- map[ii] = jj;
- id2a[jj++] = identifiers.get(ii);
- } else {
- map[ii] = -1;
-
- int classId = object2classId.get(ii);
- ClassImpl clazz = classesById.get(classId);
-
- int arraySize = preA2size.get(ii);
- if (arraySize > 0) {
- clazz.removeInstance(arraySize);
- } else {
- // [INFO] some instances of java.lang.Class are not
- // reported as HPROF_GC_CLASS_DUMP but as
- // HPROF_GC_INSTANCE_DUMP
- ClassImpl c = classesById.get(ii);
-
- if (c == null) {
- clazz.removeInstance(clazz.getHeapSizePerInstance());
- } else {
- clazz.removeInstance(c.getUsedHeapSize());
- classes2remove.add(c);
- }
- }
- }
- }
-
- // classes cannot be removed right away
- // as they are needed to remove instances of this class
- for (ClassImpl c : classes2remove) {
- classesById.remove(c.getObjectId());
-
- ClassImpl superclass = classesById.get(c.getSuperClassId());
- if (superclass != null) superclass.removeSubClass(c);
- }
-
- reachable = null; // early gc...
-
- identifiers.close();
- identifiers.delete();
- identifiers = null;
-
- if (listener.isCanceled()) throw new IProgressListener.OperationCanceledException();
- listener.worked(1); // 4
- listener.subTask(Messages.GarbageCleaner_ReIndexingClasses.pattern);
-
- // fix classes
- HashMapIntObject<ClassImpl> classesByNewId =
- new HashMapIntObject<ClassImpl>(classesById.size());
- for (Iterator<ClassImpl> iter = classesById.values(); iter.hasNext(); ) {
- ClassImpl clazz = iter.next();
- int index = map[clazz.getObjectId()];
- clazz.setObjectId(index);
-
- if (clazz.getSuperClassId() >= 0) // java.lang.Object
- {
- clazz.setSuperClassIndex(map[clazz.getSuperClassId()]);
- }
- clazz.setClassLoaderIndex(map[clazz.getClassLoaderId()]);
-
- classesByNewId.put(index, clazz);
- }
-
- idx.getSnapshotInfo().setNumberOfClasses(classesByNewId.size());
-
- if (listener.isCanceled()) throw new IProgressListener.OperationCanceledException();
- listener.worked(1); // 5
-
- // //////////////////////////////////////////////////////////////
- // identifiers
- // //////////////////////////////////////////////////////////////
-
- File indexFile = Index.IDENTIFIER.getFile(idx.snapshotInfo.getPrefix());
- listener.subTask(
- MessageUtil.format(Messages.GarbageCleaner_Writing, indexFile.getAbsolutePath()));
- idxManager.setReader(Index.IDENTIFIER,
- new IndexWriter.LongIndexStreamer().writeTo(indexFile, id2a));
-
- if (listener.isCanceled()) throw new IProgressListener.OperationCanceledException();
- listener.worked(1); // 6
-
- // //////////////////////////////////////////////////////////////
- // object 2 class Id
- // //////////////////////////////////////////////////////////////
-
- indexFile = Index.O2CLASS.getFile(idx.snapshotInfo.getPrefix());
- listener.subTask(
- MessageUtil.format(Messages.GarbageCleaner_Writing, indexFile.getAbsolutePath()));
- idxManager.setReader(Index.O2CLASS,
- new IndexWriter.IntIndexStreamer().writeTo(indexFile, new NewObjectIntIterator() {
- @Override int doGetNextInt(int index) {
- return map[idx.object2classId.get(nextIndex)];
- // return
- // map[object2classId.get(nextIndex)];
- }
-
- @Override int[] getMap() {
- return map;
- }
- }));
-
- object2classId.close();
- object2classId.delete();
- object2classId = null;
-
- if (listener.isCanceled()) throw new IProgressListener.OperationCanceledException();
- listener.worked(1); // 7
-
- // //////////////////////////////////////////////////////////////
- // array size
- // //////////////////////////////////////////////////////////////
-
- indexFile = Index.A2SIZE.getFile(idx.snapshotInfo.getPrefix());
- listener.subTask(MessageUtil.format(Messages.GarbageCleaner_Writing, new Object[] {
- indexFile.getAbsolutePath()
- }));
- final BitField arrayObjects = new BitField(newNoOfObjects);
- // arrayObjects
- idxManager.setReader(Index.A2SIZE,
- new IndexWriter.IntIndexStreamer().writeTo(indexFile, new NewObjectIntIterator() {
- IOne2OneIndex a2size = preA2size;
- int newIndex = 0;
-
- @Override int doGetNextInt(int index) {
- int size = a2size.get(nextIndex);
- if (size > 0) arrayObjects.set(newIndex);
- newIndex++;
- return size;
- }
-
- @Override int[] getMap() {
- return map;
- }
- }));
-
- preA2size.close();
- preA2size.delete();
-
- if (listener.isCanceled()) throw new IProgressListener.OperationCanceledException();
- listener.worked(1); // 9
-
- // //////////////////////////////////////////////////////////////
- // inbound, outbound
- // //////////////////////////////////////////////////////////////
-
- listener.subTask(Messages.GarbageCleaner_ReIndexingOutboundIndex.pattern);
-
- IndexWriter.IntArray1NSortedWriter w_out =
- new IndexWriter.IntArray1NSortedWriter(newNoOfObjects,
- IndexManager.Index.OUTBOUND.getFile(idx.snapshotInfo.getPrefix()));
- IndexWriter.InboundWriter w_in = new IndexWriter.InboundWriter(newNoOfObjects,
- IndexManager.Index.INBOUND.getFile(idx.snapshotInfo.getPrefix()));
-
- for (int ii = 0; ii < oldNoOfObjects; ii++) {
- int k = map[ii];
- if (k < 0) continue;
-
- int[] a = preOutbound.get(ii);
- int[] tl = new int[a.length];
- for (int jj = 0; jj < a.length; jj++) {
- int t = map[a[jj]];
-
- /* No check if the referenced objects are alive */
- /* The garbage can't be reached from a live object */
- // removed if (t >= 0) ...
- tl[jj] = t;
- w_in.log(t, k, jj == 0);
- }
-
- w_out.log(k, tl);
- }
-
- preOutbound.close();
- preOutbound.delete();
- preOutbound = null;
-
- if (listener.isCanceled()) {
- w_in.cancel();
- w_out.cancel();
- throw new IProgressListener.OperationCanceledException();
- }
- listener.worked(1); // 10
-
- listener.subTask(MessageUtil.format(Messages.GarbageCleaner_Writing,
- w_in.getIndexFile().getAbsolutePath()));
-
- idxManager.setReader(Index.INBOUND, w_in.flush(listener, new KeyWriterImpl(classesByNewId)));
- w_in = null;
- if (listener.isCanceled()) {
- w_out.cancel();
- throw new IProgressListener.OperationCanceledException();
- }
-
- listener.worked(1); // 11
-
- listener.subTask(MessageUtil.format(Messages.GarbageCleaner_Writing, new Object[] {
- w_out.getIndexFile().getAbsolutePath()
- }));
- idxManager.setReader(Index.OUTBOUND, w_out.flush());
- w_out = null;
- if (listener.isCanceled()) throw new IProgressListener.OperationCanceledException();
- listener.worked(1); // 12
-
- // fix roots
- HashMapIntObject<XGCRootInfo[]> roots = fix(idx.gcRoots, map);
- idx.getSnapshotInfo().setNumberOfGCRoots(roots.size());
-
- // fix threads 2 objects 2 roots
- HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> rootsPerThread =
- new HashMapIntObject<HashMapIntObject<XGCRootInfo[]>>();
- for (IteratorInt iter = idx.thread2objects2roots.keys(); iter.hasNext(); ) {
- int threadId = iter.next();
- int fixedThreadId = map[threadId];
- if (fixedThreadId < 0) continue;
-
- rootsPerThread.put(fixedThreadId, fix(idx.thread2objects2roots.get(threadId), map));
- }
-
- // fill stuff into builder
- builder.setIndexManager(idxManager);
- builder.setClassCache(classesByNewId);
- builder.setArrayObjects(arrayObjects);
- builder.setRoots(roots);
- builder.setRootsPerThread(rootsPerThread);
-
- return map;
- } finally {
- // delete all temporary indices
- idx.delete();
-
- if (idxManager != null && listener.isCanceled()) idxManager.delete();
- }
- }
-
- private static HashMapIntObject<XGCRootInfo[]> fix(HashMapIntObject<List<XGCRootInfo>> roots,
- final int[] map) {
- HashMapIntObject<XGCRootInfo[]> answer = new HashMapIntObject<XGCRootInfo[]>(roots.size());
- for (Iterator<List<XGCRootInfo>> iter = roots.values(); iter.hasNext(); ) {
- List<XGCRootInfo> r = iter.next();
- XGCRootInfo[] a = new XGCRootInfo[r.size()];
- for (int ii = 0; ii < a.length; ii++) {
- a[ii] = r.get(ii);
- a[ii].setObjectId(map[a[ii].getObjectId()]);
- if (a[ii].getContextAddress() != 0) a[ii].setContextId(map[a[ii].getContextId()]);
- }
-
- answer.put(a[0].getObjectId(), a);
- }
- return answer;
- }
-
- private static abstract class NewObjectIterator {
- int nextIndex = -1;
- int[] $map;
-
- public NewObjectIterator() {
- $map = getMap();
- findNext();
- }
-
- protected void findNext() {
- nextIndex++;
- while (nextIndex < $map.length && $map[nextIndex] < 0) nextIndex++;
- }
-
- public boolean hasNext() {
- return nextIndex < $map.length;
- }
-
- abstract int[] getMap();
- }
-
- private static abstract class NewObjectIntIterator extends NewObjectIterator
- implements IteratorInt {
- public int next() {
- int answer = doGetNextInt(nextIndex);
- findNext();
- return answer;
- }
-
- abstract int doGetNextInt(int nextIndex);
- }
-
- private static class KeyWriterImpl implements IndexWriter.KeyWriter {
- HashMapIntObject<ClassImpl> classesByNewId;
-
- KeyWriterImpl(HashMapIntObject<ClassImpl> classesByNewId) {
- this.classesByNewId = classesByNewId;
- }
-
- public void storeKey(int index, Serializable key) {
- ClassImpl impl = classesByNewId.get(index);
- impl.setCacheEntry(key);
- }
- }
-
- // //////////////////////////////////////////////////////////////
- // create histogram of unreachable objects
- // //////////////////////////////////////////////////////////////
-
- // private static final class Record
- // {
- // ClassImpl clazz;
- // int objectCount;
- // long size;
- //
- // public Record(ClassImpl clazz)
- // {
- // this.clazz = clazz;
- // }
- // }
-
- // private static void createHistogramOfUnreachableObjects(PreliminaryIndexImpl idx, boolean[] reachable)
- // {
- // IOne2OneIndex array2size = idx.array2size;
- //
- // HashMapIntObject<Record> histogram = new HashMapIntObject<Record>();
- //
- // int totalObjectCount = 0;
- // long totalSize = 0;
- //
- // for (int ii = 0; ii < reachable.length; ii++)
- // {
- // if (!reachable[ii])
- // {
- // int classId = idx.object2classId.get(ii);
- //
- // Record r = histogram.get(classId);
- // if (r == null)
- // {
- // ClassImpl clazz = idx.classesById.get(classId);
- // r = new Record(clazz);
- // histogram.put(classId, r);
- // }
- //
- // r.objectCount++;
- // totalObjectCount++;
- // int s = 0;
- //
- // s = array2size.get(ii);
- // if (s > 0)
- // {
- // // Already got the size
- // }
- // else if (IClass.JAVA_LANG_CLASS.equals(r.clazz.getName()))
- // {
- // ClassImpl classImpl = idx.classesById.get(ii);
- // if (classImpl == null)
- // {
- // s = r.clazz.getHeapSizePerInstance();
- // }
- // else
- // {
- // s = classImpl.getUsedHeapSize();
- // }
- // }
- // else
- // {
- // s = r.clazz.getHeapSizePerInstance();
- // }
- // r.size += s;
- // totalSize += s;
- // }
- // }
- //
- // List<UnreachableObjectsHistogram.Record> records = new ArrayList<UnreachableObjectsHistogram.Record>();
- // for (Iterator<Record> iter = histogram.values(); iter.hasNext();)
- // {
- // Record r = iter.next();
- // records.add(new UnreachableObjectsHistogram.Record(r.clazz.getName(), r.clazz.getObjectAddress(), r.objectCount, r.size));
- // }
- //
- // UnreachableObjectsHistogram deadObjectHistogram = new UnreachableObjectsHistogram(records);
- // idx.getSnapshotInfo().setProperty(UnreachableObjectsHistogram.class.getName(), deadObjectHistogram);
- // }
-
- // //////////////////////////////////////////////////////////////
- // mark unreachable objects as GC unknown
- // //////////////////////////////////////////////////////////////
-
- private static void markUnreachbleAsGCRoots(final PreliminaryIndexImpl idx, //
- boolean[] reachable, //
- int noReachableObjects, //
- int extraRootType, IProgressListener listener) {
- final int noOfObjects = reachable.length;
- final IOne2LongIndex identifiers = idx.identifiers;
- final IOne2ManyIndex preOutbound = idx.outbound;
-
- int root[] = new int[1];
- ObjectMarker marker =
- new ObjectMarker(root, reachable, preOutbound, new SilentProgressListener(listener));
-
- // find objects not referenced by any other object
- boolean inbounds[] = new boolean[noOfObjects];
- for (int ii = 0; ii < noOfObjects; ++ii) {
- if (!reachable[ii]) {
- // We only need search the unreachable objects as
- // the reachable ones will have already marked
- // its outbound refs.
- for (int out : preOutbound.get(ii))
- inbounds[out] = true;
- }
- }
-
- for (int pass = 0; pass < 2; ++pass) {
- // First pass mark only the unreferenced objects, second
- // pass do everything else
- for (int ii = 0; ii < noOfObjects && noReachableObjects < noOfObjects; ++ii) {
- // Do the objects with no inbounds first
- if (!reachable[ii] && (pass == 1 || !inbounds[ii])) {
- // Identify this unreachable object as a root,
- // and see what else is now reachable
- // No need to mark it as the marker will do that
- root[0] = ii;
-
- XGCRootInfo xgc = new XGCRootInfo(identifiers.get(ii), 0, extraRootType);
- xgc.setObjectId(ii);
-
- ArrayList<XGCRootInfo> xgcs = new ArrayList<XGCRootInfo>(1);
- xgcs.add(xgc);
- idx.gcRoots.put(ii, xgcs);
-
- int marked = marker.markSingleThreaded();
- noReachableObjects += marked;
- }
- }
- }
-
- // update GC root information
- idx.setGcRoots(idx.gcRoots);
- idx.getSnapshotInfo().setNumberOfGCRoots(idx.gcRoots.size());
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/PreliminaryIndexImpl.java b/src/main/java/org/eclipse/mat/parser/internal/PreliminaryIndexImpl.java
deleted file mode 100644
index eb6517c..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/PreliminaryIndexImpl.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal;
-
-import java.util.List;
-import org.eclipse.mat.collect.HashMapIntObject;
-import org.eclipse.mat.parser.IPreliminaryIndex;
-import org.eclipse.mat.parser.index.IIndexReader;
-import org.eclipse.mat.parser.model.ClassImpl;
-import org.eclipse.mat.parser.model.XGCRootInfo;
-import org.eclipse.mat.parser.model.XSnapshotInfo;
-
-/* package */class PreliminaryIndexImpl implements IPreliminaryIndex {
- XSnapshotInfo snapshotInfo;
-
- // id -> class impl
- HashMapIntObject<ClassImpl> classesById;
-
- // GC roots (by ids)
- HashMapIntObject<List<XGCRootInfo>> gcRoots;
- HashMapIntObject<HashMapIntObject<List<XGCRootInfo>>> thread2objects2roots;
-
- // id -> id*
- IIndexReader.IOne2ManyIndex outbound = null;
-
- // id -> address
- IIndexReader.IOne2LongIndex identifiers = null;
-
- // id -> id
- IIndexReader.IOne2OneIndex object2classId = null;
-
- // id -> int (size)
- IIndexReader.IOne2OneIndex array2size = null;
-
- public PreliminaryIndexImpl(XSnapshotInfo snapshotInfo) {
- this.snapshotInfo = snapshotInfo;
- }
-
- public XSnapshotInfo getSnapshotInfo() {
- return snapshotInfo;
- }
-
- public void setClassesById(HashMapIntObject<ClassImpl> classesById) {
- this.classesById = classesById;
- }
-
- public void setGcRoots(HashMapIntObject<List<XGCRootInfo>> gcRoots) {
- this.gcRoots = gcRoots;
- }
-
- public void setThread2objects2roots(
- HashMapIntObject<HashMapIntObject<List<XGCRootInfo>>> thread2objects2roots) {
- this.thread2objects2roots = thread2objects2roots;
- }
-
- public void setOutbound(IIndexReader.IOne2ManyIndex outbound) {
- this.outbound = outbound;
- }
-
- public void setIdentifiers(IIndexReader.IOne2LongIndex identifiers) {
- this.identifiers = identifiers;
- }
-
- public void setObject2classId(IIndexReader.IOne2OneIndex object2classId) {
- this.object2classId = object2classId;
- }
-
- public void setArray2size(IIndexReader.IOne2OneIndex array2size) {
- this.array2size = array2size;
- }
-
- public void delete() {
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/SnapshotFactory.java b/src/main/java/org/eclipse/mat/parser/internal/SnapshotFactory.java
deleted file mode 100644
index c0c3cd6..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/SnapshotFactory.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.parser.IIndexBuilder;
-import org.eclipse.mat.parser.internal.util.ParserRegistry;
-import org.eclipse.mat.parser.internal.util.ParserRegistry.Parser;
-import org.eclipse.mat.parser.model.XSnapshotInfo;
-import org.eclipse.mat.snapshot.ISnapshot;
-import org.eclipse.mat.snapshot.model.GCRootInfo;
-import org.eclipse.mat.util.IProgressListener;
-import org.eclipse.mat.util.MessageUtil;
-
-public class SnapshotFactory {
- private static class SnapshotEntry {
- private int usageCount;
- private WeakReference<ISnapshot> snapshot;
-
- public SnapshotEntry(int usageCount, ISnapshot snapshot) {
- this.usageCount = usageCount;
- this.snapshot = new WeakReference<ISnapshot>(snapshot);
- }
- }
-
- private Map<File, SnapshotEntry> snapshotCache = new HashMap<File, SnapshotEntry>();
-
- public ISnapshot openSnapshot(File file, Map<String, String> args, IProgressListener listener)
- throws SnapshotException {
- ISnapshot answer = null;
-
- // lookup in cache
- SnapshotEntry entry = snapshotCache.get(file);
- if (entry != null) {
- answer = entry.snapshot.get();
-
- if (answer != null) {
- entry.usageCount++;
- return answer;
- }
- }
-
- String name = file.getAbsolutePath();
-
- int p = name.lastIndexOf('.');
- String prefix = p >= 0 ? name.substring(0, p + 1) : name + ".";//$NON-NLS-1$
-
- deleteIndexFiles(file);
- answer = parse(file, prefix, args, listener);
-
- entry = new SnapshotEntry(1, answer);
-
- snapshotCache.put(file, entry);
-
- return answer;
- }
-
- public synchronized void dispose(ISnapshot snapshot) {
-
- for (Iterator<SnapshotEntry> iter = snapshotCache.values().iterator(); iter.hasNext(); ) {
- SnapshotEntry entry = iter.next();
-
- ISnapshot s = entry.snapshot.get();
- if (s == null) {
- iter.remove();
- } else if (s == snapshot) {
- entry.usageCount--;
- if (entry.usageCount == 0) {
- snapshot.dispose();
- iter.remove();
- }
- return;
- }
- }
-
- // just in case the snapshot is not stored anymore
- if (snapshot != null) snapshot.dispose();
- }
-
- // public IOQLQuery createQuery(String queryString) throws SnapshotException
- // {
- // return new OQLQueryImpl(queryString);
- // }
-
- // public List<SnapshotFormat> getSupportedFormats()
- // {
- // List<SnapshotFormat> answer = new ArrayList<SnapshotFormat>();
- //
- // for (Parser parser : ParserPlugin.getDefault().getParserRegistry().delegates())
- // answer.add(parser.getSnapshotFormat());
- //
- // return answer;
- // }
-
- // //////////////////////////////////////////////////////////////
- // Internal implementations
- // //////////////////////////////////////////////////////////////
-
- private ISnapshot parse(File file, String prefix, Map<String, String> args,
- IProgressListener listener) throws SnapshotException {
- List<ParserRegistry.Parser> parsers = ParserRegistry.matchParser(file.getName());
- if (parsers.isEmpty()) parsers.addAll(ParserRegistry.allParsers()); // try all...
-
- List<IOException> errors = new ArrayList<IOException>();
-
- for (Parser parser : parsers) {
- IIndexBuilder indexBuilder = parser.getIndexBuilder();
-
- if (indexBuilder == null) continue;
-
- try {
- indexBuilder.init(file, prefix);
-
- XSnapshotInfo snapshotInfo = new XSnapshotInfo();
- snapshotInfo.setPath(file.getAbsolutePath());
- snapshotInfo.setPrefix(prefix);
- snapshotInfo.setProperty("$heapFormat", parser.getId());//$NON-NLS-1$
- if (Boolean.parseBoolean(args.get("keep_unreachable_objects")))//$NON-NLS-1$
- {
- snapshotInfo.setProperty("keep_unreachable_objects",
- GCRootInfo.Type.UNREACHABLE);//$NON-NLS-1$
- }
- PreliminaryIndexImpl idx = new PreliminaryIndexImpl(snapshotInfo);
-
- indexBuilder.fill(idx, listener);
-
- SnapshotImplBuilder builder = new SnapshotImplBuilder(idx.getSnapshotInfo());
-
- int[] purgedMapping = GarbageCleaner.clean(idx, builder, args, listener);
-
- indexBuilder.clean(purgedMapping, listener);
-
- SnapshotImpl snapshot = builder.create(parser);
-
- snapshot.calculateDominatorTree(listener);
-
- return snapshot;
- } catch (IOException ioe) {
- errors.add(ioe);
- indexBuilder.cancel();
- } catch (Exception e) {
- indexBuilder.cancel();
-
- throw SnapshotException.rethrow(e);
- }
- }
-
- throw new SnapshotException(
- MessageUtil.format(Messages.SnapshotFactoryImpl_Error_NoParserRegistered, file.getName()));
- }
-
- private void deleteIndexFiles(File file) {
- File directory = file.getParentFile();
- if (directory == null) directory = new File("."); //$NON-NLS-1$
-
- String filename = file.getName();
-
- int p = filename.lastIndexOf('.');
- final String fragment = p >= 0 ? filename.substring(0, p) : filename;
- final Pattern indexPattern = Pattern.compile("\\.(.*\\.)?index$");//$NON-NLS-1$
- final Pattern logPattern = Pattern.compile("\\.inbound\\.index.*\\.log$");//$NON-NLS-1$
-
- File[] files = directory.listFiles(new FileFilter() {
- public boolean accept(File f) {
- if (f.isDirectory()) return false;
-
- String name = f.getName();
- return name.startsWith(fragment) && (indexPattern.matcher(name).matches()
- || logPattern.matcher(name).matches());
- }
- });
-
- if (files != null) {
- for (File f : files)
- f.delete();
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/SnapshotImpl.java b/src/main/java/org/eclipse/mat/parser/internal/SnapshotImpl.java
deleted file mode 100644
index 78f224c..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/SnapshotImpl.java
+++ /dev/null
@@ -1,1692 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.ArrayInt;
-import org.eclipse.mat.collect.ArrayIntBig;
-import org.eclipse.mat.collect.BitField;
-import org.eclipse.mat.collect.HashMapIntObject;
-import org.eclipse.mat.collect.IteratorInt;
-import org.eclipse.mat.collect.SetInt;
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.parser.IObjectReader;
-import org.eclipse.mat.parser.index.IIndexReader;
-import org.eclipse.mat.parser.index.IIndexReader.IOne2OneIndex;
-import org.eclipse.mat.parser.index.IndexManager;
-import org.eclipse.mat.parser.internal.snapshot.MultiplePathsFromGCRootsComputerImpl;
-import org.eclipse.mat.parser.internal.snapshot.ObjectCache;
-import org.eclipse.mat.parser.internal.snapshot.ObjectMarker;
-import org.eclipse.mat.parser.internal.snapshot.PathsFromGCRootsTreeBuilder;
-import org.eclipse.mat.parser.internal.snapshot.RetainedSizeCache;
-import org.eclipse.mat.parser.internal.util.IntStack;
-import org.eclipse.mat.parser.model.AbstractObjectImpl;
-import org.eclipse.mat.parser.model.ClassImpl;
-import org.eclipse.mat.parser.model.ClassLoaderImpl;
-import org.eclipse.mat.parser.model.InstanceImpl;
-import org.eclipse.mat.parser.model.XGCRootInfo;
-import org.eclipse.mat.parser.model.XSnapshotInfo;
-import org.eclipse.mat.snapshot.DominatorsSummary;
-import org.eclipse.mat.snapshot.DominatorsSummary.ClassDominatorRecord;
-import org.eclipse.mat.snapshot.ExcludedReferencesDescriptor;
-import org.eclipse.mat.snapshot.IMultiplePathsFromGCRootsComputer;
-import org.eclipse.mat.snapshot.IPathsFromGCRootsComputer;
-import org.eclipse.mat.snapshot.ISnapshot;
-import org.eclipse.mat.snapshot.PathsFromGCRootsTree;
-import org.eclipse.mat.snapshot.model.GCRootInfo;
-import org.eclipse.mat.snapshot.model.IClass;
-import org.eclipse.mat.snapshot.model.IObject;
-import org.eclipse.mat.snapshot.model.IThreadStack;
-import org.eclipse.mat.snapshot.model.NamedReference;
-import org.eclipse.mat.util.IProgressListener;
-import org.eclipse.mat.util.IProgressListener.OperationCanceledException;
-import org.eclipse.mat.util.MessageUtil;
-import org.eclipse.mat.util.VoidProgressListener;
-
-public final class SnapshotImpl implements ISnapshot {
-
- // //////////////////////////////////////////////////////////////
- // factory methods
- // //////////////////////////////////////////////////////////////
-
- public static SnapshotImpl create(XSnapshotInfo snapshotInfo, //
- IObjectReader heapObjectReader, //
- HashMapIntObject<ClassImpl> classCache, //
- HashMapIntObject<XGCRootInfo[]> roots, //
- HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> rootsPerThread, //
- BitField arrayObjects, //
- IndexManager indexManager) throws IOException, SnapshotException {
- SnapshotImpl answer =
- new SnapshotImpl(snapshotInfo, heapObjectReader, classCache, roots, rootsPerThread, null,
- arrayObjects, indexManager);
- answer.calculateLoaderLabels();
- return answer;
- }
-
- // //////////////////////////////////////////////////////////////
- // member variables
- // //////////////////////////////////////////////////////////////
-
- // serialized data
- private XSnapshotInfo snapshotInfo;
- private HashMapIntObject<ClassImpl> classCache;
- private HashMapIntObject<XGCRootInfo[]> roots;
- private HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> rootsPerThread;
-
- private HashMapIntObject<String> loaderLabels;
- private BitField arrayObjects;
-
- // stored in separate files
- private IndexManager indexManager;
- private RetainedSizeCache retainedSizeCache;
-
- // runtime data
- private IObjectReader heapObjectReader;
- private boolean dominatorTreeCalculated;
- private Map<String, List<IClass>> classCacheByName;
- private ObjectCache<IObject> objectCache;
-
- private boolean parsedThreads = false;
- HashMapIntObject<IThreadStack> threadId2stack;
-
- // //////////////////////////////////////////////////////////////
- // constructor
- // //////////////////////////////////////////////////////////////
-
- private SnapshotImpl(XSnapshotInfo snapshotInfo, //
- IObjectReader heapObjectReader, //
- HashMapIntObject<ClassImpl> classCache, //
- HashMapIntObject<XGCRootInfo[]> roots, //
- HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> rootsPerThread, //
- HashMapIntObject<String> loaderLabels, //
- BitField arrayObjects, //
- IndexManager indexManager) throws SnapshotException, IOException {
- this.snapshotInfo = snapshotInfo;
- this.heapObjectReader = heapObjectReader;
- this.classCache = classCache;
- this.roots = roots;
- this.rootsPerThread = rootsPerThread;
- this.loaderLabels = loaderLabels;
- this.arrayObjects = arrayObjects;
- this.indexManager = indexManager;
-
- // initialize data
- this.retainedSizeCache = new RetainedSizeCache(snapshotInfo);
-
- this.classCacheByName = new HashMap<String, List<IClass>>(this.classCache.size());
- for (Iterator<ClassImpl> iter = this.classCache.values(); iter.hasNext(); ) {
- ClassImpl clasz = iter.next();
- clasz.setSnapshot(this);
-
- List<IClass> list = classCacheByName.get(clasz.getName());
- if (list == null) classCacheByName.put(clasz.getName(), list = new ArrayList<IClass>());
- list.add(clasz);
- }
-
- this.dominatorTreeCalculated = indexManager.dominated() != null
- && indexManager.o2retained() != null
- && indexManager.dominator() != null;
-
- this.objectCache = new HeapObjectCache(this, 1000);
-
- this.heapObjectReader.open(this);
-
- // Object unreach = snapshotInfo.getProperty(UnreachableObjectsHistogram.class.getName());
- // if (unreach instanceof UnreachableObjectsHistogram)
- // ((UnreachableObjectsHistogram)unreach).setSnapshot(this);
- }
-
- private void calculateLoaderLabels() throws SnapshotException {
- loaderLabels = new HashMapIntObject<String>();
- long usedHeapSize = 0;
-
- int systemClassLoaderId = indexManager.o2address().reverse(0);
-
- Object[] classes = classCache.getAllValues();
- for (int i = 0; i < classes.length; i++) {
- ClassImpl clasz = (ClassImpl) classes[i];
- usedHeapSize += clasz.getTotalSize();
-
- int classLoaderId = clasz.getClassLoaderId();
- String label = loaderLabels.get(classLoaderId);
- if (label != null) continue;
-
- if (classLoaderId == systemClassLoaderId) {
- label = "<system class loader>";//$NON-NLS-1$
- } else {
- IObject classLoader = getObject(classLoaderId);
- label = classLoader.getClassSpecificName();
- if (label == null) label = ClassLoaderImpl.NO_LABEL;
- }
-
- loaderLabels.put(classLoaderId, label);
- }
-
- // now, let's go through all instances of all sub classes to attach
- // labels
- Collection<IClass> loaderClasses = getClassesByName(IClass.JAVA_LANG_CLASSLOADER, true);
- if (loaderClasses != null) {
- for (IClass clazz : loaderClasses) {
- for (int classLoaderId : clazz.getObjectIds()) {
- String label = loaderLabels.get(classLoaderId);
- if (label != null) continue;
-
- if (classLoaderId == systemClassLoaderId) {
- label = "<system class loader>";//$NON-NLS-1$
- } else {
- IObject classLoader = getObject(classLoaderId);
- label = classLoader.getClassSpecificName();
- if (label == null) label = ClassLoaderImpl.NO_LABEL;
- }
-
- loaderLabels.put(classLoaderId, label);
- }
- }
- }
-
- snapshotInfo.setUsedHeapSize(usedHeapSize);
- // numberOfObjects was previously calculated by summing getNumberOfObjects() for
- // each class. Sometimes there was a mismatch. See bug 294311
- snapshotInfo.setNumberOfObjects(indexManager.idx.size());
- snapshotInfo.setNumberOfClassLoaders(loaderLabels.size());
- snapshotInfo.setNumberOfGCRoots(roots.size());
- snapshotInfo.setNumberOfClasses(classCache.size());
-
- // important: refresh object cache. To calculate the loader labels, the
- // class loader instances are loaded. however, the object cache uses the
- // loader label to determine the implementation class. hence, cached
- // instances from creating the labels have the wrong implementation
- // class. hence, the refresh.
- objectCache.clear();
- }
-
- // //////////////////////////////////////////////////////////////
- // interface implementation
- // //////////////////////////////////////////////////////////////
-
- public XSnapshotInfo getSnapshotInfo() {
- return snapshotInfo;
- }
-
- public int[] getGCRoots() throws SnapshotException {
- return roots.getAllKeys();
- // return Arrays.asList((GCRootInfo[]) roots.getAllValues(new
- // GCRootInfo[roots.size()]));
- }
-
- public Collection<IClass> getClasses() throws SnapshotException {
- return Arrays.asList(classCache.getAllValues(new IClass[classCache.size()]));
- }
-
- public Collection<IClass> getClassesByName(String name, boolean includeSubClasses)
- throws SnapshotException {
- List<IClass> list = this.classCacheByName.get(name);
- if (list == null) return null;
-
- if (!includeSubClasses) return Collections.unmodifiableCollection(list);
-
- // use set to filter out duplicate subclasses
- Set<IClass> answer = new HashSet<IClass>();
- answer.addAll(list);
- for (IClass clazz : list)
- answer.addAll(clazz.getAllSubclasses());
- return answer;
- }
-
- public Collection<IClass> getClassesByName(Pattern namePattern, boolean includeSubClasses)
- throws SnapshotException {
- Set<IClass> result = new HashSet<IClass>();
- Object[] classes = classCache.getAllValues();
- for (int i = 0; i < classes.length; i++) {
- IClass clazz = (IClass) classes[i];
- if (namePattern.matcher(clazz.getName()).matches()) {
- result.add(clazz);
- if (includeSubClasses) {
- result.addAll(clazz.getAllSubclasses());
- }
- }
- }
- return result;
- }
-
- // public Histogram getHistogram(IProgressListener listener) throws SnapshotException
- // {
- // if (listener == null)
- // listener = new VoidProgressListener();
- //
- // HistogramBuilder histogramBuilder = new HistogramBuilder(Messages.SnapshotImpl_Histogram);
- //
- // Object[] classes = classCache.getAllValues();
- // for (int i = 0; i < classes.length; i++)
- // {
- // histogramBuilder.put(new XClassHistogramRecord((ClassImpl) classes[i]));
- // }
- //
- // if (listener.isCanceled())
- // throw new IProgressListener.OperationCanceledException();
- //
- // return histogramBuilder.toHistogram(this, true);
- // }
- //
- // public Histogram getHistogram(int[] objectIds, IProgressListener progressMonitor) throws SnapshotException
- // {
- // if (progressMonitor == null)
- // progressMonitor = new VoidProgressListener();
- //
- // HistogramBuilder histogramBuilder = new HistogramBuilder(Messages.SnapshotImpl_Histogram);
- //
- // progressMonitor.beginTask(Messages.SnapshotImpl_BuildingHistogram, objectIds.length >>> 8);
- //
- // // Arrays.sort(objectIds);
- // // int[] classIds = indexManager.o2class().getAll(objectIds);
- //
- // IOne2OneIndex o2class = indexManager.o2class();
- //
- // int classId;
- //
- // for (int ii = 0; ii < objectIds.length; ii++)
- // {
- // classId = o2class.get(objectIds[ii]);
- //
- // histogramBuilder.add(classId, objectIds[ii], getHeapSize(objectIds[ii]));
- //
- // if ((ii & 0xff) == 0)
- // {
- // if (progressMonitor.isCanceled())
- // return null;
- // progressMonitor.worked(1);
- // }
- // }
- //
- // progressMonitor.done();
- // return histogramBuilder.toHistogram(this, false);
- // }
-
- public int[] getInboundRefererIds(int objectId) throws SnapshotException {
- return indexManager.inbound().get(objectId);
- }
-
- public int[] getOutboundReferentIds(int objectId) throws SnapshotException {
- return indexManager.outbound().get(objectId);
- }
-
- public int[] getInboundRefererIds(int[] objectIds, IProgressListener progressMonitor)
- throws SnapshotException {
- if (progressMonitor == null) progressMonitor = new VoidProgressListener();
-
- IIndexReader.IOne2ManyIndex inbound = indexManager.inbound();
-
- SetInt result = new SetInt();
- progressMonitor.beginTask(Messages.SnapshotImpl_ReadingInboundReferrers,
- objectIds.length / 100);
-
- for (int ii = 0; ii < objectIds.length; ii++) {
- int[] referees = inbound.get(objectIds[ii]);
- for (int refereeId : referees)
- result.add(refereeId);
-
- if (ii % 100 == 0) {
- if (progressMonitor.isCanceled()) return null;
- progressMonitor.worked(1);
- }
- }
-
- int[] endResult = result.toArray();
- // It used to be sorted before (TreeSet<Integer>) but I don't
- // remember if this is needed
- // Arrays.sort(endResult);
-
- progressMonitor.done();
-
- return endResult;
- }
-
- public int[] getOutboundReferentIds(int[] objectIds, IProgressListener progressMonitor)
- throws SnapshotException {
- if (progressMonitor == null) progressMonitor = new VoidProgressListener();
-
- IIndexReader.IOne2ManyIndex outbound = indexManager.outbound();
-
- SetInt result = new SetInt();
- progressMonitor.beginTask(Messages.SnapshotImpl_ReadingOutboundReferrers,
- objectIds.length / 100);
-
- for (int ii = 0; ii < objectIds.length; ii++) {
- int[] referees = outbound.get(objectIds[ii]);
- for (int refereeId : referees)
- result.add(refereeId);
-
- if (ii % 100 == 0) {
- if (progressMonitor.isCanceled()) return null;
- progressMonitor.worked(1);
- }
- }
-
- int[] endResult = result.toArray();
-
- progressMonitor.done();
-
- return endResult;
- }
-
- public IPathsFromGCRootsComputer getPathsFromGCRoots(int objectId,
- Map<IClass, Set<String>> excludeList) throws SnapshotException {
- return new PathsFromGCRootsComputerImpl(objectId, excludeList);
- }
-
- public IMultiplePathsFromGCRootsComputer getMultiplePathsFromGCRoots(int[] objectIds,
- Map<IClass, Set<String>> excludeList) throws SnapshotException {
- return new MultiplePathsFromGCRootsComputerImpl(objectIds, excludeList, this);
- }
-
- int[] getRetainedSetSingleThreaded(int[] objectIds, IProgressListener progressMonitor)
- throws SnapshotException {
- /* for empty initial set - return immediately an empty retained set */
- if (objectIds.length == 0) {
- return new int[0];
- }
-
- /*
- * take the retained set of a single object out of the dominator tree -
- * it's faster
- */
- if (objectIds.length == 1) {
- return getSingleObjectRetainedSet(objectIds[0]);
- }
-
- int numberOfObjects = snapshotInfo.getNumberOfObjects();
-
- if (progressMonitor == null) progressMonitor = new VoidProgressListener();
-
- /* a bit field to mark all reached objects */
- boolean[] reachable = new boolean[numberOfObjects];
-
- /*
- * Initially mark all the objects whose retained set is to be calculated
- * Thus the dfs will not go through this objects, and all objects
- * retained from them will stay unmarked (the bits will be clear)
- */
- for (int objId : objectIds) {
- reachable[objId] = true;
- }
-
- /*
- * The dfs() will start from the GC roots, follow the outbound
- * references, and mark all unmarked objects. The retained set will
- * contain the unmarked objects
- */
- ObjectMarker marker =
- new ObjectMarker(roots.getAllKeys(), reachable, indexManager.outbound(), progressMonitor);
- int numReached;
- try {
- numReached = marker.markSingleThreaded();
- } catch (OperationCanceledException e) {
- // $JL-EXC$
- return null;
- }
-
- // int numReached = dfs(reachable);
- int[] retained = new int[numberOfObjects - numReached];
-
- /*
- * Unmark also the initial objects, as we want them to be included in
- * the retained set
- */
- for (int objId : objectIds) {
- reachable[objId] = false;
- }
-
- /* Put each unmarked bit into the retained set */
- int j = 0;
- for (int i = 0; i < numberOfObjects; i++) {
- if (!reachable[i]) {
- retained[j++] = i;
- }
- }
- return retained;
- }
-
- private int[] getRetainedSetMultiThreaded(int[] objectIds, int availableProcessors,
- IProgressListener progressMonitor) throws SnapshotException {
- /* for empty initial set - return immediately an empty retained set */
- if (objectIds.length == 0) {
- return new int[0];
- }
-
- /*
- * take the retained set of a single object out of the dominator tree -
- * it's faster
- */
- if (objectIds.length == 1) {
- return getSingleObjectRetainedSet(objectIds[0]);
- }
-
- int numberOfObjects = snapshotInfo.getNumberOfObjects();
-
- if (progressMonitor == null) progressMonitor = new VoidProgressListener();
-
- /* a boolean[] to mark all reached objects */
- boolean[] reachable = new boolean[numberOfObjects];
-
- /*
- * Initially mark all the objects whose retained set is to be calculated
- * Thus the dfs will not go through this objects, and all objects
- * retained from them will stay unmarked (the bits will be clear)
- */
- for (int objId : objectIds) {
- reachable[objId] = true;
- }
-
- /*
- * Mark all the GC roots, and keep them in a stack. The worker threads
- * are going to pop() one by one the gc roots and do the marking from
- * them
- */
- int[] gcRoots = roots.getAllKeys();
- ObjectMarker marker =
- new ObjectMarker(gcRoots, reachable, indexManager.outbound(), progressMonitor);
- try {
- marker.markMultiThreaded(availableProcessors);
- } catch (InterruptedException e) {
- throw new SnapshotException(e);
- }
-
- /*
- * Unmark also the initial objects, as we want them to be included in
- * the retained set
- */
- for (int objId : objectIds) {
- reachable[objId] = false;
- }
-
- /*
- * build the result in an IntArray - the exact number of marked is not
- * known
- */
- ArrayIntBig retained = new ArrayIntBig();
-
- /* Put each unmarked object into the retained set */
- for (int i = 0; i < numberOfObjects; i++) {
- if (!reachable[i]) {
- retained.add(i);
- }
- }
- return retained.toArray();
- }
-
- public int[] getRetainedSet(int[] objectIds, IProgressListener progressMonitor)
- throws SnapshotException {
- int availableProcessors = Runtime.getRuntime().availableProcessors();
- if (availableProcessors > 1) {
- return getRetainedSetMultiThreaded(objectIds, availableProcessors, progressMonitor);
- } else {
- return getRetainedSetSingleThreaded(objectIds, progressMonitor);
- }
- }
-
- public int[] getRetainedSet(int[] objectIds, String[] fieldNames, IProgressListener listener)
- throws SnapshotException {
- if (objectIds.length == 0) {
- return new int[0];
- }
-
- int numberOfObjects = indexManager.o2address().size();
-
- if (listener == null) listener = new VoidProgressListener();
-
- BitField initialSet = new BitField(numberOfObjects);
- for (int objId : objectIds)
- initialSet.set(objId);
-
- if (listener.isCanceled()) return null;
-
- BitField reachable = new BitField(numberOfObjects);
-
- int markedObjects = dfs2(reachable, initialSet, fieldNames);
-
- int[] retained = new int[numberOfObjects - markedObjects];
- int j = 0;
- for (int i = 0; i < numberOfObjects; i++) {
- if (!reachable.get(i)) {
- retained[j++] = i;
- }
- }
-
- return retained;
- }
-
- public int[] getRetainedSet(int[] objectIds, ExcludedReferencesDescriptor[] excludedReferences,
- IProgressListener progressMonitor) throws SnapshotException {
- /*
- * first pass - mark starting from the GC roots, avoiding
- * excludedReferences, until initial are reached. The non-marked objects
- * will be a common retained set from the excluded and initial objects
- */
- boolean[] firstPass = new boolean[getSnapshotInfo().getNumberOfObjects()];
- // mark all initial
- for (int objId : objectIds) {
- firstPass[objId] = true;
- }
- ObjectMarker marker = new ObjectMarker(getGCRoots(), firstPass, getIndexManager().outbound,
- new VoidProgressListener());
- marker.markSingleThreaded(excludedReferences, this);
-
- // un-mark initial - they have to go into the retained set
- for (int objId : objectIds) {
- firstPass[objId] = false;
- }
-
- /*
- * Second pass - from the non-marked objects mark the ones starting from
- * the initial set (objectIds)
- */
- boolean[] secondPass = new boolean[firstPass.length];
- System.arraycopy(firstPass, 0, secondPass, 0, firstPass.length);
-
- ObjectMarker secondMarker = new ObjectMarker(objectIds, secondPass, getIndexManager().outbound,
- new VoidProgressListener());
- secondMarker.markSingleThreaded();
-
- /*
- * Have to merge the results of the two markings here
- */
- int numObjects = getSnapshotInfo().getNumberOfObjects();
- ArrayIntBig retainedSet = new ArrayIntBig();
- for (int i = 0; i < numObjects; i++) {
- if (!firstPass[i] && secondPass[i]) {
- retainedSet.add(i);
- }
- }
- return retainedSet.toArray();
- }
-
- public long getMinRetainedSize(int[] objectIds, IProgressListener progressMonitor)
- throws UnsupportedOperationException, SnapshotException {
- if (objectIds.length == 1) {
- return getRetainedHeapSize(objectIds[0]);
- }
- if (objectIds.length == 0) {
- return 0;
- }
-
- // to get the min.retained size we do not need to find the min.retain
- // set at all
- // all one needs is the distinct objects in the dominator tree. The
- // sum of their retained sizes is the correct value then
- int[] topAncestors = getTopAncestorsInDominatorTree(objectIds, progressMonitor);
- long result = 0;
- for (int topAncestorId : topAncestors) {
- result += getRetainedHeapSize(topAncestorId);
- }
- return result;
- }
-
- public int[] getMinRetainedSet(int[] objectIds, IProgressListener progressMonitor)
- throws UnsupportedOperationException, SnapshotException {
- if (objectIds.length == 1) {
- return getSingleObjectRetainedSet(objectIds[0]);
- }
-
- SetInt retainedSet = new SetInt(2 * objectIds.length);
- for (int i : objectIds) {
- retainedSet.add(i);
- }
-
- /*
- * objects on the path from a top-ancestor to the <root> will be saved
- * here to avoid walking the same path many times
- */
- SetInt negativeCache = new SetInt(2 * objectIds.length);
-
- // used to temporarily keep the walked-through objects before we decide
- // in which cache to store them
- // inline the stack functionality for performance reasons
- // IntStack temp = new IntStack();
- int tempSize = 0;
- int tempCapacity = 10 * 1024;
- int[] temp = new int[tempCapacity];
-
- IIndexReader.IOne2OneIndex dominatorIdx = indexManager.dominator();
- IIndexReader.IOne2ManyIndex dominated = indexManager.dominated();
-
- int size = 0;
- int capacity = 10 * 1024;
- int[] stack = new int[capacity];
-
- int iterations = 0;
- for (int objectId : objectIds) {
-
- iterations++;
- if ((iterations & 0xffff) == 0) {
- if (progressMonitor.isCanceled()) {
- throw new IProgressListener.OperationCanceledException();
- }
- }
-
- int dominatorId = dominatorIdx.get(objectId) - 2;
- boolean save = true;
-
- /*
- * For each object walk up the dominator tree until either the
- * <root> is reached or an object which is already in the retained
- * set
- */
- while (dominatorId > -1) {
- // temp.push(dominatorId); // save all objects on the path
- if (tempSize == tempCapacity) {
- int newCapacity = tempCapacity << 1;
- int[] newArr = new int[newCapacity];
- System.arraycopy(temp, 0, newArr, 0, tempCapacity);
- temp = newArr;
- tempCapacity = newCapacity;
- }
- temp[tempSize++] = dominatorId;
- // end of push()
-
- // check if the dominator is in the retained set (i.e. there
- // is another object from the initial set dominating it)
- if (retainedSet.contains(dominatorId)) {
- save = false;
- break;
- }
-
- // check if the dominator is in the negative cache - i.e. there
- // are no objects from the initial set on the way to the <root>
- if (negativeCache.contains(dominatorId)) {
- // save is true, so simply break and let the result be saved
- break;
- }
- dominatorId = dominatorIdx.get(dominatorId) - 2;
- }
- if (save) {
- // add the path from the object up to the <root> to the negative
- // cache
- while (tempSize > 0) {
- // negativeCache.add(temp.pop());
- negativeCache.add(temp[--tempSize]); // pop
- }
-
- /*
- * Add the the objects retained by objectId to the whole
- * retained set. Always use one and the same stack, it is empty
- * at the end of this block
- */
-
- stack[size++] = objectId; // push
-
- int current;
-
- while (size > 0) // are there elements in the stack?
- {
- current = stack[--size]; // pop
- retainedSet.add(current);
-
- int[] next = dominated.get(current + 1);
- for (int i : next) {
- // push, check capacity first
- if (size == capacity) {
- int newCapacity = capacity << 1;
- int[] newArr = new int[newCapacity];
- System.arraycopy(stack, 0, newArr, 0, capacity);
- stack = newArr;
- capacity = newCapacity;
- }
- stack[size++] = i;
- }
- }
- }
- }
-
- return retainedSet.toArray();
- }
-
- public int[] getTopAncestorsInDominatorTree(int[] objectIds, IProgressListener listener)
- throws SnapshotException {
- if (!isDominatorTreeCalculated()) {
- throw new SnapshotException(Messages.SnapshotImpl_Error_DomTreeNotAvailable);
- }
-
- if (listener == null) listener = new VoidProgressListener();
-
- /*
- * For big objects sets use a boolean[] instead of SetInt to mark
- * processed objects SetInt is too memory expensive and on huge sets may
- * lead to an OOMError Using the boolean[] is also faster on bigger
- * sets.
- */
- if (objectIds.length > 1000000) return getTopAncestorsWithBooleanCache(objectIds, listener);
-
- /*
- * objects on the path from a top-ancestor to the <root> will be saved
- * here to avoid walking the same path many times
- */
- SetInt negativeCache = new SetInt(objectIds.length);
-
- /*
- * objects on the path to a top-ancestor will be cached here, to avoid
- * walking the same path multiple times.
- */
- SetInt positiveCache = new SetInt(2 * objectIds.length);
- for (int i : objectIds) {
- positiveCache.add(i);
- }
-
- /*
- * an array where all top-ancestors will be saved
- */
- ArrayInt result = new ArrayInt();
-
- // used to temporarily keep the walked-through objects before we decide
- // in which cache to store them
- // inline the stack functionality for performance reasons
- // IntStack temp = new IntStack();
- int tempSize = 0;
- int tempCapacity = 10 * 1024;
- int[] temp = new int[tempCapacity];
-
- IIndexReader.IOne2OneIndex dominatorIdx = indexManager.dominator();
-
- int iterations = 0;
- for (int objectId : objectIds) {
- iterations++;
- if ((iterations & 0xffff) == 0) {
- if (listener.isCanceled()) {
- throw new IProgressListener.OperationCanceledException();
- }
- }
-
- int dominatorId = dominatorIdx.get(objectId) - 2;
- boolean save = true;
-
- /*
- * For each object walk up the dominator tree until either the
- * <root> is reached or an object which is already in the retained
- * set
- */
- while (dominatorId > -1) {
- // temp.push(dominatorId); // save all objects on the path
- if (tempSize == tempCapacity) {
- int newCapacity = tempCapacity << 1;
- int[] newArr = new int[newCapacity];
- System.arraycopy(temp, 0, newArr, 0, tempCapacity);
- temp = newArr;
- tempCapacity = newCapacity;
- }
- temp[tempSize++] = dominatorId;
-
- // check if the dominator is in the positive cache (i.e. there
- // is another object from the initial set dominating it)
- if (positiveCache.contains(dominatorId)) {
- save = false;
- // add the marked objects to the positiveCache
- while (tempSize > 0) {
- // positiveCahce.add(temp.pop());
- positiveCache.add(temp[--tempSize]); // pop
- }
- break;
- }
-
- // check if the dominator is in the negative cache - i.e. there
- // are no objects from the initial set on the way to the <root>
- if (negativeCache.contains(dominatorId)) {
- // save is true, so simply break and let the result be saved
- break;
- }
- dominatorId = dominatorIdx.get(dominatorId) - 2;
- }
- if (save) {
- result.add(objectId);
- while (tempSize > 0) {
- // negativeCache.add(temp.pop());
- negativeCache.add(temp[--tempSize]); // pop
- }
- }
- }
-
- return result.toArray();
- }
-
- private int[] getTopAncestorsWithBooleanCache(int[] objectIds, IProgressListener listener) {
- /*
- * objects on the path from a top-ancestor to the <root> will be saved
- * here to avoid walking the same path many times
- */
- boolean[] negativeCache = new boolean[snapshotInfo.getNumberOfObjects()];
-
- /*
- * objects on the path to a top-ancestor will be cached here, to avoid
- * walking the same path multiple times.
- */
- boolean[] positiveCache = new boolean[snapshotInfo.getNumberOfObjects()];
- for (int i : objectIds) {
- positiveCache[i] = true;
- }
-
- /*
- * an array where all top-ancestors will be saved
- */
- ArrayInt result = new ArrayInt();
-
- // used to temporarily keep the walked-through objects before we decide
- // in which cache to store them
- // inline the stack functionality for performance reasons
- // IntStack temp = new IntStack();
- int tempSize = 0;
- int tempCapacity = 10 * 1024;
- int[] temp = new int[tempCapacity];
-
- IIndexReader.IOne2OneIndex dominatorIdx = indexManager.dominator();
-
- int iterations = 0;
- for (int objectId : objectIds) {
- iterations++;
- if ((iterations & 0xffff) == 0) {
- if (listener.isCanceled()) {
- throw new IProgressListener.OperationCanceledException();
- }
- }
-
- int dominatorId = dominatorIdx.get(objectId) - 2;
- boolean save = true;
-
- /*
- * For each object walk up the dominator tree until either the
- * <root> is reached or an object which is already in the retained
- * set
- */
- while (dominatorId > -1) {
- // temp.push(dominatorId); // save all objects on the path
- if (tempSize == tempCapacity) {
- int newCapacity = tempCapacity << 1;
- int[] newArr = new int[newCapacity];
- System.arraycopy(temp, 0, newArr, 0, tempCapacity);
- temp = newArr;
- tempCapacity = newCapacity;
- }
- temp[tempSize++] = dominatorId;
-
- // check if the dominator is in the positive cache (i.e. there
- // is another object from the initial set dominating it)
- if (positiveCache[dominatorId]) {
- save = false;
- // add the marked objects to the positiveCache
- while (tempSize > 0) {
- // positiveCahce.add(temp.pop());
- positiveCache[temp[--tempSize]] = true; // pop
- }
- break;
- }
-
- // check if the dominator is in the negative cache - i.e. there
- // are no objects from the initial set on the way to the <root>
- if (negativeCache[dominatorId]) {
- // save is true, so simply break and let the result be saved
- break;
- }
- dominatorId = dominatorIdx.get(dominatorId) - 2;
- }
- if (save) {
- result.add(objectId);
- while (tempSize > 0) {
- // negativeCache.add(temp.pop());
- negativeCache[temp[--tempSize]] = true; // pop
- }
- }
- }
-
- return result.toArray();
- }
-
- private boolean isDominatorTreeCalculated() {
- return dominatorTreeCalculated;
- }
-
- public void calculateDominatorTree(IProgressListener listener)
- throws SnapshotException, IProgressListener.OperationCanceledException {
- try {
- DominatorTree.calculate(this, listener);
- dominatorTreeCalculated = indexManager.dominated() != null
- && indexManager.o2retained() != null
- && indexManager.dominator() != null;
- } catch (IOException e) {
- throw new SnapshotException(e);
- }
- }
-
- public int[] getImmediateDominatedIds(int objectId) throws SnapshotException {
- if (!isDominatorTreeCalculated()) {
- throw new SnapshotException(Messages.SnapshotImpl_Error_DomTreeNotAvailable);
- }
- return indexManager.dominated().get(objectId + 1);
- }
-
- public int getImmediateDominatorId(int objectId) throws SnapshotException {
- if (!isDominatorTreeCalculated()) {
- throw new SnapshotException(Messages.SnapshotImpl_Error_DomTreeNotAvailable);
- }
- return indexManager.dominator().get(objectId) - 2;
- }
-
- public DominatorsSummary getDominatorsOf(int[] objectIds, Pattern excludePattern,
- IProgressListener progressListener) throws SnapshotException {
- if (!isDominatorTreeCalculated()) {
- throw new SnapshotException(Messages.SnapshotImpl_Error_DomTreeNotAvailable);
- }
-
- if (progressListener == null) progressListener = new VoidProgressListener();
-
- IIndexReader.IOne2OneIndex dominatorIndex = indexManager.dominator();
- IIndexReader.IOne2OneIndex o2classIndex = indexManager.o2class();
-
- SetInt excludeSet = new SetInt();
- SetInt includeSet = new SetInt();
-
- progressListener.beginTask(Messages.SnapshotImpl_RetrievingDominators, objectIds.length / 10);
-
- Map<IClass, DominatorsSummary.ClassDominatorRecord> map =
- new HashMap<IClass, DominatorsSummary.ClassDominatorRecord>();
- for (int ii = 0; ii < objectIds.length; ii++) {
- int objectId = objectIds[ii];
-
- int domClassId;
- IClass clasz;
- String domClassName;
-
- // the values in the index are 2+the real value
- int dominatorId = dominatorIndex.get(objectId) - 2;
- if (dominatorId == -1) {
- clasz = null;
- domClassName = "<ROOT>";//$NON-NLS-1$
- domClassId = -1;
- } else {
- domClassId = o2classIndex.get(dominatorId);
- clasz = classCache.get(domClassId);
- domClassName = clasz.getName();
- }
-
- if (excludePattern != null && dominatorId >= 0) {
- boolean exclude = true;
- while (exclude) {
- if (progressListener.isCanceled()) {
- throw new IProgressListener.OperationCanceledException();
- }
-
- // check the negative cache first
- if (excludeSet.contains(domClassId)) {
- // the values in the index are 2+the real value
- dominatorId = dominatorIndex.get(dominatorId) - 2;
- if (dominatorId == -1) {
- clasz = null;
- domClassName = "<ROOT>";//$NON-NLS-1$
- domClassId = -1;
- } else {
- domClassId = o2classIndex.get(dominatorId);
- clasz = classCache.get(domClassId);
- domClassName = clasz.getName();
- }
- }
- // then check the positive cache
- else if (includeSet.contains(domClassId)) {
- exclude = false;
- }
- // the class has not been processed so far
- else {
- if (excludePattern.matcher(domClassName).matches() && dominatorId >= 0) {
- // just add the classId to the exclude cache
- // the next iteration will get the next dominator
- excludeSet.add(domClassId);
- } else {
- includeSet.add(domClassId);
- exclude = false;
- }
- }
- }
- }
-
- DominatorsSummary.ClassDominatorRecord record = map.get(clasz);
- if (record == null) {
- record = new DominatorsSummary.ClassDominatorRecord();
- map.put(clasz, record);
- record.setClassName(domClassName);
- record.setClassId(domClassId);
- record.setClassloaderId(dominatorId == -1 || clasz == null ? -1 : clasz.getClassLoaderId());
- }
-
- if (record.addDominator(dominatorId) && dominatorId != -1) {
- record.addDominatorNetSize(getHeapSize(dominatorId));
- }
- if (record.addDominated(objectId)) record.addDominatedNetSize(getHeapSize(objectId));
-
- if (ii % 10 == 0) {
- if (progressListener.isCanceled()) throw new IProgressListener.OperationCanceledException();
- progressListener.worked(1);
- }
- }
-
- ClassDominatorRecord[] records =
- map.values().toArray(new DominatorsSummary.ClassDominatorRecord[0]);
-
- progressListener.done();
-
- return new DominatorsSummary(records, this);
- }
-
- public IObject getObject(int objectId) throws SnapshotException {
- IObject answer = this.classCache.get(objectId);
- if (answer != null) return answer;
-
- return this.objectCache.get(objectId);
- }
-
- public GCRootInfo[] getGCRootInfo(int objectId) throws SnapshotException {
- return roots.get(objectId);
- }
-
- public IClass getClassOf(int objectId) throws SnapshotException {
- if (isClass(objectId)) {
- return getObject(objectId).getClazz();
- } else {
- return (IClass) getObject(indexManager.o2class().get(objectId));
- }
- }
-
- public long mapIdToAddress(int objectId) throws SnapshotException {
- return indexManager.o2address().get(objectId);
- }
-
- public int getHeapSize(int objectId) throws SnapshotException {
- if (arrayObjects.get(objectId)) {
- return indexManager.a2size().get(objectId);
- } else {
- IClass clazz = classCache.get(objectId);
-
- if (clazz != null) {
- // it is a class
- return clazz.getUsedHeapSize();
- } else {
- // it is an instance
- clazz = classCache.get(indexManager.o2class().get(objectId));
- return clazz.getHeapSizePerInstance();
- }
- }
- }
-
- public long getHeapSize(int[] objectIds) throws UnsupportedOperationException, SnapshotException {
- long total = 0;
- IOne2OneIndex o2class = indexManager.o2class();
- IOne2OneIndex a2size = indexManager.a2size();
- for (int objectId : objectIds) {
- if (arrayObjects.get(objectId)) // take array sizes from another
- // index
- {
- total += a2size.get(objectId);
- } else {
- IClass clazz = classCache.get(objectId);
-
- if (clazz != null) {
- // it is a class
- total += clazz.getUsedHeapSize();
- } else {
- // it is an instance
- clazz = classCache.get(o2class.get(objectId));
- total += clazz.getHeapSizePerInstance();
- }
- }
- }
- return total;
- }
-
- public long getRetainedHeapSize(int objectId) throws SnapshotException {
- if (this.isDominatorTreeCalculated()) {
- return indexManager.o2retained().get(objectId);
- } else {
- return 0;
- }
- }
-
- public boolean isArray(int objectId) {
- if (arrayObjects.get(objectId)) {
- // Variable size, so see if actually an array
- IClass clazz = classCache.get(indexManager.o2class().get(objectId));
- if (clazz.isArrayType()) {
- return true;
- } else {
- return false;
- }
- }
- return false;
- }
-
- public boolean isClass(int objectId) {
- return classCache.containsKey(objectId);
- }
-
- public boolean isGCRoot(int objectId) {
- return roots.containsKey(objectId);
- }
-
- public int mapAddressToId(long objectAddress) throws SnapshotException {
- int objectId = indexManager.o2address().reverse(objectAddress);
- if (objectId < 0) {
- throw new SnapshotException(
- MessageUtil.format(Messages.SnapshotImpl_Error_ObjectNotFound, new Object[] {
- "0x" //$NON-NLS-1$
- + Long.toHexString(objectAddress)
- }));
- }
- return objectId;
- }
-
- public void dispose() {
- IOException error = null;
-
- try {
- heapObjectReader.close();
- } catch (IOException e1) {
- error = e1;
- }
-
- try {
- indexManager.close();
- } catch (IOException e1) {
- error = e1;
- }
-
- retainedSizeCache.close();
-
- if (error != null) throw new RuntimeException(error);
- }
-
- // //////////////////////////////////////////////////////////////
- // internal stuff
- // //////////////////////////////////////////////////////////////
-
- public List<IClass> resolveClassHierarchy(int classIndex) {
- IClass clazz = classCache.get(classIndex);
- if (clazz == null) return null;
-
- List<IClass> answer = new ArrayList<IClass>();
- answer.add(clazz);
- while (clazz.hasSuperClass()) {
- clazz = classCache.get(clazz.getSuperClassId());
- if (clazz == null) return null;
- answer.add(clazz);
- }
-
- return answer;
- }
-
- /** performance improved check if the object is a class loader */
- public boolean isClassLoader(int objectId) {
- return loaderLabels.containsKey(objectId);
- }
-
- public String getClassLoaderLabel(int objectId) {
- return loaderLabels.get(objectId);
- }
-
- public void setClassLoaderLabel(int objectId, String label) {
- if (label == null) throw new NullPointerException(Messages.SnapshotImpl_Label.pattern);
-
- String old = loaderLabels.put(objectId, label);
- if (old == null) {
- throw new RuntimeException(
- Messages.SnapshotImpl_Error_ReplacingNonExistentClassLoader.pattern);
- }
- }
-
- private int dfs2(BitField bits, BitField exclude, String[] fieldNames) throws SnapshotException {
- int count = 0;
-
- HashSet<String> fieldNamesSet = new HashSet<String>(fieldNames.length);
- for (int i = 0; i < fieldNames.length; i++) {
- fieldNamesSet.add(fieldNames[i]);
- }
-
- IIndexReader.IOne2ManyIndex outbound = indexManager.outbound();
-
- IntStack stack = new IntStack();
-
- for (IteratorInt en = roots.keys(); en.hasNext(); ) {
- int i = en.next();
- stack.push(i);
- bits.set(i);
- count++;
- }
-
- int current;
-
- while (stack.size() > 0) {
- current = stack.pop();
- if (exclude.get(current)) {
- // check for objects which are only referenced by the desired
- // fields
- for (int child : outbound.get(current)) {
- // well, we must load the obj
- IObject obj = getObject(current);
- long childAddress = mapIdToAddress(child);
-
- List<NamedReference> refs = obj.getOutboundReferences();
- for (NamedReference reference : refs) {
- // if there is a ref from a not-specified field - put
- // the child
- // on the list. This means it's not part of the desired
- // retained set
- if (!bits.get(child)
- && reference.getObjectAddress() == childAddress
- && !fieldNamesSet.contains(reference.getName())) {
- stack.push(child);
- bits.set(child);
- count++;
- }
- }
- }
- } else {
- for (int child : outbound.get(current)) {
- if (!bits.get(child)) {
- stack.push(child);
- bits.set(child);
- count++;
- }
- }
- }
- }
-
- return count;
- }
-
- private int[] getSingleObjectRetainedSet(int objectId) throws SnapshotException {
- ArrayIntBig result = new ArrayIntBig();
- IntStack stack = new IntStack();
-
- stack.push(objectId);
-
- int current;
-
- while (stack.size() > 0) {
- current = stack.pop();
- result.add(current);
-
- int[] next = getImmediateDominatedIds(current);
- for (int i : next) {
- stack.push(i);
- }
- }
-
- return result.toArray();
- }
-
- private static class Path {
-
- int index;
- Path next;
-
- public Path(int index, Path next) {
- this.index = index;
- this.next = next;
- }
-
- public Path getNext() {
- return next;
- }
-
- public int getIndex() {
- return index;
- }
-
- public boolean contains(long id) {
- Path p = this;
- while (p != null) {
- if (p.index == id) return true;
- p = p.next;
- }
- return false;
- }
- }
-
- private class PathsFromGCRootsComputerImpl implements IPathsFromGCRootsComputer {
- /*
- * special state of the path computer 0 initial; 1 final; 2 processing a
- * GC root; 3 normal processing
- */
- private int state;
-
- private int nextState;
-
- int objectId;
- LinkedList<Path> fifo = new LinkedList<Path>();
- BitField visited = new BitField(indexManager.o2address().size());
- BitField excludeInstances;
- IIndexReader.IOne2ManyIndex inboundIndex; // to avoid method calls to
-
- int currentId;
- Path currentPath;
- int[] currentReferrers;
- int lastReadReferrer;
-
- int[] referringThreads;
- int currentReferringThread;
- int[] foundPath;
-
- Map<IClass, Set<String>> excludeMap;
-
- public PathsFromGCRootsComputerImpl(int objectId, Map<IClass, Set<String>> excludeMap)
- throws SnapshotException {
- this.objectId = objectId;
- this.excludeMap = excludeMap;
- inboundIndex = indexManager.inbound();
-
- if (excludeMap != null) {
- initExcludeInstances();
- }
-
- currentId = objectId;
-
- visited.set(objectId);
- if (roots.get(objectId) != null) {
- // leave the fifo empty
- } else {
- fifo.add(new Path(objectId, null));
- }
- }
-
- private void initExcludeInstances() throws SnapshotException {
- excludeInstances = new BitField(indexManager.o2address().size());
- for (IClass clazz : excludeMap.keySet()) {
- int[] objects = clazz.getObjectIds();
- for (int objId : objects) {
- excludeInstances.set(objId);
- }
- }
- }
-
- private boolean refersOnlyThroughExcluded(int referrerId, int referentId)
- throws SnapshotException {
- if (!excludeInstances.get(referrerId)) return false;
-
- IObject referrerObject = getObject(referrerId);
- Set<String> excludeFields = excludeMap.get(referrerObject.getClazz());
- if (excludeFields == null) return true; // treat null as all fields
-
- long referentAddr = mapIdToAddress(referentId);
-
- List<NamedReference> refs = referrerObject.getOutboundReferences();
- for (NamedReference reference : refs) {
- if (referentAddr == reference.getObjectAddress() && !excludeFields.contains(
- reference.getName())) {
- return false;
- }
- }
- return true;
- }
-
- public int[] getNextShortestPath() throws SnapshotException {
- switch (state) {
- case 0: // INITIAL
- {
- /*
- * some special check if the initial object itself is a GC
- * root usually the GC roots are found among the referrers
- */
- if (roots.containsKey(currentId)) {
- referringThreads = null;
- state = 2; // PROCESSING GC ROOT
- nextState = 1; // FINAL
- foundPath = new int[] { currentId };
- return getNextShortestPath();
- } else {
- state = 3; // NORMAL
- return getNextShortestPath();
- }
- }
- case 1: // FINAL
- return null;
-
- case 2: // PROCESSING GC ROOT
- {
- if (referringThreads == null) {
- referringThreads = getReferringTreads(getGCRootInfo(foundPath[foundPath.length - 1]));
- currentReferringThread = 0;
- if (referringThreads.length == 0) {
- // there were no threads found to refer to this GC
- // root
- state = nextState;
- return foundPath;
- }
- }
- if (currentReferringThread < referringThreads.length) {
- int[] result = new int[foundPath.length + 1];
- System.arraycopy(foundPath, 0, result, 0, foundPath.length);
- result[result.length - 1] = referringThreads[currentReferringThread];
-
- currentReferringThread++;
- return result;
- } else {
- state = nextState;
- return getNextShortestPath();
- }
- }
- case 3: // NORMAL PROCESSING
- {
- int[] res;
-
- // finish processing the current entry
- if (currentReferrers != null) {
- res = processCurrentReferrefs(lastReadReferrer + 1);
- if (res != null) return res;
- }
-
- // Continue with the FIFO
- while (fifo.size() > 0) {
- currentPath = fifo.getFirst();
- fifo.removeFirst();
- currentId = currentPath.getIndex();
- currentReferrers = inboundIndex.get(currentId);
-
- if (currentReferrers != null) {
- res = processCurrentReferrefs(0);
- if (res != null) return res;
- }
- }
- return null;
- }
-
- default:
- throw new RuntimeException(Messages.SnapshotImpl_Error_UnrecognizedState.pattern + state);
- }
- }
-
- private int[] getReferringTreads(GCRootInfo[] rootInfos) {
- SetInt threads = new SetInt();
- for (GCRootInfo info : rootInfos) {
- // add only threads different from the current GC root
- if (info.getContextAddress() != 0 && info.getObjectAddress() != info.getContextAddress()) {
- threads.add(info.getContextId());
- }
- }
- return threads.toArray();
- }
-
- public PathsFromGCRootsTree getTree(Collection<int[]> paths) {
- PathsFromGCRootsTreeBuilder rootBuilder = new PathsFromGCRootsTreeBuilder(objectId);
- for (int[] path : paths) {
- PathsFromGCRootsTreeBuilder current = rootBuilder;
-
- /*
- * now add the path as a branch start from 1, as path[0] is the
- * starting object
- */
- for (int k = 1; k < path.length; k++) {
- int childId = path[k];
- PathsFromGCRootsTreeBuilder child = current.getObjectReferers().get(childId);
- if (child == null) {
- child = new PathsFromGCRootsTreeBuilder(childId);
- current.addObjectReferer(child);
- }
- current = child;
- }
- }
-
- return rootBuilder.toPathsFromGCRootsTree();
- }
-
- private int[] path2Int(Path p) {
- IntStack s = new IntStack();
- while (p != null) {
- s.push(p.getIndex());
- p = p.getNext();
- }
- int res[] = new int[s.size()];
- for (int i = 0; i < res.length; i++) {
- res[i] = s.pop();
- }
- return res;
- }
-
- private int[] processCurrentReferrefs(int fromIndex) throws SnapshotException {
- GCRootInfo[] rootInfo = null;
- for (int i = fromIndex; i < currentReferrers.length; i++) {
- rootInfo = roots.get(currentReferrers[i]);
- if (rootInfo != null) {
- if (excludeMap == null) {
- // save state
- lastReadReferrer = i;
- Path p = new Path(currentReferrers[i], currentPath);
- referringThreads = null;
- state = 2; // FOUND GC ROOT
- nextState = 3; // NORMAL PROCESSING
- foundPath = path2Int(p);
- return getNextShortestPath();
- } else {
- if (!refersOnlyThroughExcluded(currentReferrers[i], currentId)) {
- // save state
- lastReadReferrer = i;
- Path p = new Path(currentReferrers[i], currentPath);
- referringThreads = null;
- state = 2; // FOUND GC ROOT
- nextState = 3; // NORMAL PROCESSING
- foundPath = path2Int(p);
- return getNextShortestPath();
- }
- }
- }
- }
- for (int referrer : currentReferrers) {
- if (referrer >= 0 && !visited.get(referrer) && !roots.containsKey(referrer)) {
- if (excludeMap == null) {
- fifo.add(new Path(referrer, currentPath));
- visited.set(referrer);
- } else {
- if (!refersOnlyThroughExcluded(referrer, currentId)) {
- fifo.add(new Path(referrer, currentPath));
- visited.set(referrer);
- }
- }
- }
- }
- return null;
- }
- }
-
- public IndexManager getIndexManager() {
- return indexManager;
- }
-
- public IObjectReader getHeapObjectReader() {
- return heapObjectReader;
- }
-
- public RetainedSizeCache getRetainedSizeCache() {
- return retainedSizeCache;
- }
-
- public HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> getRootsPerThread() {
- return rootsPerThread;
- }
-
- @SuppressWarnings("unchecked") public <A> A getSnapshotAddons(Class<A> addon)
- throws SnapshotException {
- // if (addon == UnreachableObjectsHistogram.class)
- // {
- // return (A) this.getSnapshotInfo().getProperty(UnreachableObjectsHistogram.class.getName());
- // }
- // else
- // {
- return heapObjectReader.getAddon(addon);
- // }
- }
-
- public IThreadStack getThreadStack(int objectId) throws SnapshotException {
- if (!parsedThreads) {
- threadId2stack = ThreadStackHelper.loadThreadsData(this);
- parsedThreads = true;
- }
-
- if (threadId2stack != null) {
- return threadId2stack.get(objectId);
- }
- return null;
- }
-
- // //////////////////////////////////////////////////////////////
- // private classes
- // //////////////////////////////////////////////////////////////
-
- private static final class HeapObjectCache extends ObjectCache<IObject> {
- SnapshotImpl snapshot;
-
- private HeapObjectCache(SnapshotImpl snapshot, int maxSize) {
- super(maxSize);
- this.snapshot = snapshot;
- }
-
- @Override protected IObject load(int objectId) {
- try {
- IObject answer = null;
- // check if the object is an array (no index needed)
- if (snapshot.isArray(objectId)) {
- answer = snapshot.heapObjectReader.read(objectId, snapshot);
- } else {
- ClassImpl classImpl =
- (ClassImpl) snapshot.getObject(snapshot.indexManager.o2class().get(objectId));
- if (snapshot.isClassLoader(objectId)) {
- answer = new ClassLoaderImpl(objectId, Long.MIN_VALUE, classImpl, null);
- } else {
- answer = new InstanceImpl(objectId, Long.MIN_VALUE, classImpl, null);
- }
- }
-
- ((AbstractObjectImpl) answer).setSnapshot(snapshot);
-
- return answer;
- } catch (IOException e) {
- throw new RuntimeException(e);
- } catch (SnapshotException e) {
- throw new RuntimeException(e);
- }
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/SnapshotImplBuilder.java b/src/main/java/org/eclipse/mat/parser/internal/SnapshotImplBuilder.java
deleted file mode 100644
index 6a4b0eb..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/SnapshotImplBuilder.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.BitField;
-import org.eclipse.mat.collect.HashMapIntObject;
-import org.eclipse.mat.parser.IObjectReader;
-import org.eclipse.mat.parser.index.IndexManager;
-import org.eclipse.mat.parser.internal.util.ParserRegistry.Parser;
-import org.eclipse.mat.parser.model.ClassImpl;
-import org.eclipse.mat.parser.model.XGCRootInfo;
-import org.eclipse.mat.parser.model.XSnapshotInfo;
-import org.eclipse.mat.snapshot.model.IClass;
-
-public class SnapshotImplBuilder {
- private XSnapshotInfo snapshotInfo;
- /* package */ HashMapIntObject<ClassImpl> classCache;
- /* package */ Map<String, List<IClass>> classCacheByName;
- private HashMapIntObject<XGCRootInfo[]> roots;
- private HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> rootsPerThread;
-
- /* package */ BitField arrayObjects;
-
- /* package */ IndexManager indexManager;
-
- public SnapshotImplBuilder(XSnapshotInfo snapshotInfo) {
- this.snapshotInfo = snapshotInfo;
- }
-
- public XSnapshotInfo getSnapshotInfo() {
- return snapshotInfo;
- }
-
- public void setIndexManager(IndexManager indexManager) {
- this.indexManager = indexManager;
- }
-
- public IndexManager getIndexManager() {
- return indexManager;
- }
-
- public void setClassCache(HashMapIntObject<ClassImpl> classCache) {
- this.classCache = classCache;
- }
-
- public HashMapIntObject<ClassImpl> getClassCache() {
- return classCache;
- }
-
- public void setRoots(HashMapIntObject<XGCRootInfo[]> roots) {
- this.roots = roots;
- }
-
- public HashMapIntObject<XGCRootInfo[]> getRoots() {
- return roots;
- }
-
- public void setRootsPerThread(HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> rootsPerThread) {
- this.rootsPerThread = rootsPerThread;
- }
-
- public void setArrayObjects(BitField arrayObjects) {
- this.arrayObjects = arrayObjects;
- }
-
- public SnapshotImpl create(Parser parser) throws IOException, SnapshotException {
- IObjectReader heapObjectReader = parser.getObjectReader();
- return SnapshotImpl.create(snapshotInfo, heapObjectReader, classCache, roots, rootsPerThread,
- arrayObjects, indexManager);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/StackFrameImpl.java b/src/main/java/org/eclipse/mat/parser/internal/StackFrameImpl.java
deleted file mode 100644
index 497338d..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/StackFrameImpl.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal;
-
-import org.eclipse.mat.snapshot.model.IStackFrame;
-
-/**
- * @noextend This class is not intended to be subclassed by clients. May still
- * be subject of change
- */
-class StackFrameImpl implements IStackFrame {
- private String text;
-
- private int[] localObjectIds;
-
- public StackFrameImpl(String text, int[] localObjectIds) {
- this.text = text;
- this.localObjectIds = localObjectIds;
- }
-
- public int[] getLocalObjectsIds() {
- return localObjectIds == null ? new int[0] : localObjectIds;
- }
-
- public String getText() {
- return text;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/ThreadStackHelper.java b/src/main/java/org/eclipse/mat/parser/internal/ThreadStackHelper.java
deleted file mode 100644
index d90f8c7..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/ThreadStackHelper.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.ArrayInt;
-import org.eclipse.mat.collect.HashMapIntObject;
-import org.eclipse.mat.snapshot.ISnapshot;
-import org.eclipse.mat.snapshot.model.IThreadStack;
-
-/* package */class ThreadStackHelper {
-
- /* package */
- static HashMapIntObject<IThreadStack> loadThreadsData(ISnapshot snapshot)
- throws SnapshotException {
- String fileName = snapshot.getSnapshotInfo().getPrefix() + "threads"; //$NON-NLS-1$
- File f = new File(fileName);
- if (!f.exists()) return null;
-
- HashMapIntObject<IThreadStack> threadId2stack = new HashMapIntObject<IThreadStack>();
-
- BufferedReader in = null;
- try {
- in = new BufferedReader(new FileReader(f));
- String line = in.readLine();
-
- while (line != null) {
- line = line.trim();
- if (line.startsWith("Thread")) //$NON-NLS-1$
- {
- long threadAddress = readThreadAddres(line);
- List<String> lines = new ArrayList<String>();
- HashMapIntObject<ArrayInt> line2locals = new HashMapIntObject<ArrayInt>();
-
- line = in.readLine();
- while (line != null && !line.equals("")) //$NON-NLS-1$
- {
- lines.add(line.trim());
- line = in.readLine();
- }
-
- line = in.readLine();
- if (line != null && line.trim().startsWith("locals")) //$NON-NLS-1$
- {
- line = in.readLine();
- while (line != null && !line.equals("")) //$NON-NLS-1$
- {
- int lineNr = readLineNumber(line);
- if (lineNr >= 0) {
- int objectId = readLocalId(line, snapshot);
- ArrayInt arr = line2locals.get(lineNr);
- if (arr == null) {
- arr = new ArrayInt();
- line2locals.put(lineNr, arr);
- }
- arr.add(objectId);
- }
- line = in.readLine();
- }
- }
-
- if (threadAddress != -1) {
- int threadId = snapshot.mapAddressToId(threadAddress);
- IThreadStack stack = new ThreadStackImpl(threadId, buildFrames(lines, line2locals));
- threadId2stack.put(threadId, stack);
- }
- }
-
- if (line != null) {
- line = in.readLine();
- } else {
- break;
- }
- }
- } catch (IOException e) {
- throw new SnapshotException(e);
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (Exception ignore) {
- // $JL-EXC$
- }
- }
- }
-
- return threadId2stack;
- }
-
- private static long readThreadAddres(String line) {
- int start = line.indexOf("0x"); //$NON-NLS-1$
- if (start < 0) return -1;
- return (new BigInteger(line.substring(start + 2), 16)).longValue();
- }
-
- private static int readLocalId(String line, ISnapshot snapshot) throws SnapshotException {
- int start = line.indexOf("0x"); //$NON-NLS-1$
- int end = line.indexOf(',', start);
- long address = (new BigInteger(line.substring(start + 2, end), 16)).longValue();
- return snapshot.mapAddressToId(address);
- }
-
- private static int readLineNumber(String line) {
- int start = line.indexOf("line="); //$NON-NLS-1$
- return Integer.valueOf(line.substring(start + 5));
- }
-
- private static StackFrameImpl[] buildFrames(List<String> lines,
- HashMapIntObject<ArrayInt> line2locals) {
- int sz = lines.size();
-
- StackFrameImpl[] frames = new StackFrameImpl[sz];
- for (int i = 0; i < sz; i++) {
- int[] localsIds = null;
- ArrayInt locals = line2locals.get(i);
- if (locals != null && locals.size() > 0) {
- localsIds = locals.toArray();
- }
- frames[i] = new StackFrameImpl(lines.get(i), localsIds);
- }
-
- return frames;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/ThreadStackImpl.java b/src/main/java/org/eclipse/mat/parser/internal/ThreadStackImpl.java
deleted file mode 100644
index 2adad5a..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/ThreadStackImpl.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal;
-
-import org.eclipse.mat.snapshot.model.IStackFrame;
-import org.eclipse.mat.snapshot.model.IThreadStack;
-
-/**
- * @noextend This class is not intended to be subclassed by clients. May still
- * be subject of change
- */
-class ThreadStackImpl implements IThreadStack {
- private int threadId;
- private IStackFrame[] stackFrames;
-
- public ThreadStackImpl(int threadId, StackFrameImpl[] stackFrames) {
- this.threadId = threadId;
- this.stackFrames = stackFrames;
- }
-
- public IStackFrame[] getStackFrames() {
- return stackFrames;
- }
-
- public int getThreadId() {
- return threadId;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/snapshot/MultiplePathsFromGCRootsComputerImpl.java b/src/main/java/org/eclipse/mat/parser/internal/snapshot/MultiplePathsFromGCRootsComputerImpl.java
deleted file mode 100644
index 7a36996..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/snapshot/MultiplePathsFromGCRootsComputerImpl.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal.snapshot;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.ArrayInt;
-import org.eclipse.mat.collect.BitField;
-import org.eclipse.mat.collect.QueueInt;
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.parser.index.IIndexReader;
-import org.eclipse.mat.parser.internal.SnapshotImpl;
-import org.eclipse.mat.snapshot.IMultiplePathsFromGCRootsComputer;
-import org.eclipse.mat.snapshot.MultiplePathsFromGCRootsClassRecord;
-import org.eclipse.mat.snapshot.MultiplePathsFromGCRootsRecord;
-import org.eclipse.mat.snapshot.model.IClass;
-import org.eclipse.mat.snapshot.model.IObject;
-import org.eclipse.mat.snapshot.model.NamedReference;
-import org.eclipse.mat.util.IProgressListener;
-
-public class MultiplePathsFromGCRootsComputerImpl implements IMultiplePathsFromGCRootsComputer {
-
- int[] objectIds; // the initial objects
- Object[] paths; // paths for each of the objects
-
- SnapshotImpl snapshot; // snapshot
- IIndexReader.IOne2ManyIndex outboundIndex; // outbound references index
-
- private BitField excludeInstances;
- private Map<IClass, Set<String>> excludeMap;
-
- private boolean pathsCalculated;
-
- private static final int NOT_VISITED = -2;
- private static final int NO_PARENT = -1;
-
- public MultiplePathsFromGCRootsComputerImpl(int[] objectIds, Map<IClass, Set<String>> excludeMap,
- SnapshotImpl snapshot) throws SnapshotException {
- this.snapshot = snapshot;
- this.objectIds = objectIds;
- this.excludeMap = excludeMap;
- outboundIndex = snapshot.getIndexManager().outbound;
-
- if (excludeMap != null) {
- initExcludeInstances();
- }
- }
-
- private void initExcludeInstances() throws SnapshotException {
- excludeInstances = new BitField(snapshot.getIndexManager().o2address().size());
- for (IClass clazz : excludeMap.keySet()) {
- int[] objects = clazz.getObjectIds();
- for (int objId : objects) {
- excludeInstances.set(objId);
- }
- }
- }
-
- private void computePaths(IProgressListener progressListener) throws SnapshotException {
- ArrayList<int[]> pathsList = new ArrayList<int[]>();
-
- // make a breadth first search for the objects, starting from the roots
- int[] parent = bfs(progressListener);
-
- // then get the shortest path per object
- for (int i = 0; i < objectIds.length; i++) {
- int[] path = getPathFromBFS(objectIds[i], parent);
-
- /*
- * if there is an exclude filter, for some objects there could be no
- * path, i.e. null is expected then
- */
- if (path != null) {
- pathsList.add(path);
- }
- }
-
- pathsCalculated = true;
- paths = pathsList.toArray();
- }
-
- public MultiplePathsFromGCRootsRecord[] getPathsByGCRoot(IProgressListener progressListener)
- throws SnapshotException {
- if (!pathsCalculated) {
- computePaths(progressListener);
- }
-
- MultiplePathsFromGCRootsRecord dummy = new MultiplePathsFromGCRootsRecord(-1, -1, snapshot);
- for (int i = 0; i < paths.length; i++) {
- dummy.addPath((int[]) paths[i]);
- }
-
- return dummy.nextLevel();
- }
-
- public Object[] getAllPaths(IProgressListener progressListener) throws SnapshotException {
- if (!pathsCalculated) {
- computePaths(progressListener);
- }
- return paths;
- }
-
- public MultiplePathsFromGCRootsClassRecord[] getPathsGroupedByClass(boolean startFromTheGCRoots,
- IProgressListener progressListener) throws SnapshotException {
- if (!pathsCalculated) {
- computePaths(progressListener);
- }
-
- MultiplePathsFromGCRootsClassRecord dummy =
- new MultiplePathsFromGCRootsClassRecord(null, -1, startFromTheGCRoots, snapshot);
- for (int i = 0; i < paths.length; i++) {
- dummy.addPath((int[]) paths[i]);
- }
-
- return dummy.nextLevel();
- }
-
- private boolean refersOnlyThroughExcluded(int referrerId, int referentId)
- throws SnapshotException {
- if (!excludeInstances.get(referrerId)) return false;
-
- IObject referrerObject = snapshot.getObject(referrerId);
- Set<String> excludeFields = excludeMap.get(referrerObject.getClazz());
- if (excludeFields == null) return true; // treat null as all fields
-
- long referentAddr = snapshot.mapIdToAddress(referentId);
-
- List<NamedReference> refs = referrerObject.getOutboundReferences();
- for (NamedReference reference : refs) {
- if (referentAddr == reference.getObjectAddress() && !excludeFields.contains(
- reference.getName())) {
- return false;
- }
- }
- return true;
- }
-
- private int[] bfs(IProgressListener progressListener) throws SnapshotException {
- // number objects in the heap
- final int numObjects = snapshot.getSnapshotInfo().getNumberOfObjects();
- final boolean skipReferences = excludeMap != null; // should some paths
- // be excluded?
-
- // used to store the parent of each object during the BFS
- int[] parent = new int[numObjects];
- Arrays.fill(parent, NOT_VISITED);
-
- // use boolean[numObjects] instead of SetInt, as it is faster to check
- boolean[] toBeChecked = new boolean[numObjects];
-
- int count = 0; // the number of distinct objects whose paths should be
- // calculated
- for (int i : objectIds) {
- if (!toBeChecked[i]) count++;
- toBeChecked[i] = true;
- }
-
- // use first-in-first-out to get the shortest paths
- QueueInt fifo = new QueueInt(numObjects / 8);
-
- // initially queue all GC roots
- int[] gcRoots = snapshot.getGCRoots();
- for (int root : gcRoots) {
- fifo.put(root);
- parent[root] = NO_PARENT;
- }
-
- // used for the progress listener
- int countVisitedObjects = 0;
- int reportFrequency = Math.max(10, numObjects / 100);
-
- progressListener.beginTask(Messages.MultiplePathsFromGCRootsComputerImpl_FindingPaths, 100);
-
- // loop until the queue is empty, or all necessary paths are found
- while (fifo.size() > 0 && count > 0) {
- int objectId = fifo.get();
-
- // was some of the objects of interest reached?
- if (toBeChecked[objectId]) {
- count--; // reduce the remaining work
- }
-
- // queue any unprocessed referenced object
- int[] outbound = outboundIndex.get(objectId);
- for (int child : outbound) {
- if (parent[child] == NOT_VISITED) {
- if (skipReferences) {
- if (refersOnlyThroughExcluded(objectId, child)) continue;
- }
- parent[child] = objectId;
- fifo.put(child);
- }
- }
-
- countVisitedObjects++;
- if (countVisitedObjects % reportFrequency == 0) {
- if (progressListener.isCanceled()) throw new IProgressListener.OperationCanceledException();
- progressListener.worked(1);
- }
- }
- progressListener.done();
- return parent;
- }
-
- /*
- * Returns the shortest path to an object, using the stored parent of every
- * needed object calculated during a BFS
- *
- * @param int objectId the object to which a path should be calculated
- *
- * @param int[] parent an array, result of a BSF, which keeps a parent[i] is
- * the parent of the object with index i, as calculated during the BFS
- *
- * @return int[] the shortest path from a GC root. The object of interest is
- * at index 0, the GC root at index length-1
- */
- private int[] getPathFromBFS(int objectId, int[] parent) {
- // check if the object wasn't reached at all. This may happen if some
- // paths are excluded
- if (parent[objectId] == NOT_VISITED) return null;
-
- ArrayInt path = new ArrayInt();
- while (objectId != NO_PARENT) {
- path.add(objectId);
- objectId = parent[objectId];
- }
-
- return path.toArray();
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/snapshot/ObjectCache.java b/src/main/java/org/eclipse/mat/parser/internal/snapshot/ObjectCache.java
deleted file mode 100644
index b56ce08..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/snapshot/ObjectCache.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal.snapshot;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import org.eclipse.mat.collect.HashMapIntObject;
-
-abstract public class ObjectCache<E> {
- static class Entry<E> {
- E object;
- int key;
- int numUsages;
- }
-
- private int maxSize;
- private final HashMapIntObject<Entry<E>> map;
- private final List<LinkedList<Entry<E>>> lfus;
- private int maxLfuBuckets = 0;
- private int lowestNonEmptyLfu = 0;
-
- public ObjectCache(int maxSize) {
- this.maxSize = maxSize;
- this.map = new HashMapIntObject<Entry<E>>(maxSize);
- this.lfus = new ArrayList<LinkedList<Entry<E>>>(5);
- this.maxLfuBuckets = maxSize / 3;
- }
-
- public synchronized E get(int objectId) {
- Entry<E> e = map.get(objectId);
- if (e != null) {
- revalueEntry(e);
- } else {
- e = new Entry<E>();
- e.object = load(objectId);
- e.key = objectId;
-
- doInsert(e);
-
- while (map.size() > maxSize) removeLeastValuableNode();
- }
-
- return e.object;
- }
-
- public synchronized void clear() {
- this.map.clear();
- this.lfus.clear();
- }
-
- protected abstract E load(int key);
-
- protected synchronized void doInsert(final Entry<E> e) {
- lfu(e.numUsages).addFirst(e);
- Entry<?> p = map.put(e.key, e);
- lowestNonEmptyLfu = 0;
-
- if (p != null) lfu(p.numUsages).remove(p);
- }
-
- protected final LinkedList<Entry<E>> lfu(int numUsageIndex) {
- int lfuIndex = Math.min(maxLfuBuckets, numUsageIndex);
-
- if (lfuIndex >= lfus.size()) {
- LinkedList<Entry<E>> lfu = new LinkedList<Entry<E>>();
- lfus.add(lfuIndex, lfu);
- return lfu;
- } else {
- return lfus.get(lfuIndex);
- }
- }
-
- protected void revalueEntry(Entry<E> entry) {
- LinkedList<Entry<E>> currBucket = lfu(entry.numUsages);
- LinkedList<Entry<E>> nextBucket = lfu(++entry.numUsages);
-
- currBucket.remove(entry);
- nextBucket.addFirst(entry);
- }
-
- protected LinkedList<Entry<E>> getLowestNonEmptyLfu() {
- LinkedList<Entry<E>> lfu = null;
- for (int i = lowestNonEmptyLfu; i < lfus.size(); i++) {
- lfu = lfu(i);
-
- if (lfu.size() != 0) {
- lowestNonEmptyLfu = i;
- return lfu;
- }
- }
- return lfu;
- }
-
- protected void removeLeastValuableNode() {
- LinkedList<Entry<E>> lfu = getLowestNonEmptyLfu();
- Entry<?> lln = lfu.remove(lfu.size() - 1);
- map.remove(lln.key);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/snapshot/ObjectMarker.java b/src/main/java/org/eclipse/mat/parser/internal/snapshot/ObjectMarker.java
deleted file mode 100644
index 21a1552..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/snapshot/ObjectMarker.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal.snapshot;
-
-import java.util.List;
-import java.util.Set;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.BitField;
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.parser.index.IIndexReader;
-import org.eclipse.mat.parser.internal.util.IntStack;
-import org.eclipse.mat.snapshot.ExcludedReferencesDescriptor;
-import org.eclipse.mat.snapshot.ISnapshot;
-import org.eclipse.mat.snapshot.model.IObject;
-import org.eclipse.mat.snapshot.model.NamedReference;
-import org.eclipse.mat.util.IProgressListener;
-
-public class ObjectMarker {
- int[] roots;
- boolean[] bits;
- IIndexReader.IOne2ManyIndex outbound;
- IProgressListener progressListener;
-
- public ObjectMarker(int[] roots, boolean[] bits, IIndexReader.IOne2ManyIndex outbound,
- IProgressListener progressListener) {
- this.roots = roots;
- this.bits = bits;
- this.outbound = outbound;
- this.progressListener = progressListener;
- }
-
- public int markSingleThreaded() throws IProgressListener.OperationCanceledException {
- int count = 0;
- int size = 0;
- int[] data = new int[10 * 1024]; // start with 10k
- int rootsToProcess = 0;
-
- for (int rootId : roots) {
- if (!bits[rootId]) {
- /* start stack.push() */
- if (size == data.length) {
- int[] newArr = new int[data.length << 1];
- System.arraycopy(data, 0, newArr, 0, data.length);
- data = newArr;
- }
- data[size++] = rootId;
- /* end stack.push() */
-
- bits[rootId] = true;
- count++;
-
- rootsToProcess++;
- }
- }
-
- progressListener.beginTask(Messages.ObjectMarker_CalculateRetainedSize, rootsToProcess);
-
- int current;
-
- while (size > 0) {
- /* start stack.pop() */
- current = data[--size];
-
- if (size <= rootsToProcess) {
- rootsToProcess--;
- progressListener.worked(1);
- if (progressListener.isCanceled()) throw new IProgressListener.OperationCanceledException();
- }
-
- for (int child : outbound.get(current)) {
- if (!bits[child]) {
- // stack.push(child);
- /* start stack.push() */
- if (size == data.length) {
- int[] newArr = new int[data.length << 1];
- System.arraycopy(data, 0, newArr, 0, data.length);
- data = newArr;
- }
- data[size++] = child;
- /* end stack.push() */
-
- bits[child] = true;
- count++;
- }
- }
- }
-
- progressListener.done();
-
- return count;
- }
-
- public int markSingleThreaded(ExcludedReferencesDescriptor[] excludeSets, ISnapshot snapshot)
- throws SnapshotException, IProgressListener.OperationCanceledException {
- /*
- * prepare the exclude stuff
- */
- BitField excludeObjectsBF = new BitField(snapshot.getSnapshotInfo().getNumberOfObjects());
- for (ExcludedReferencesDescriptor set : excludeSets) {
- for (int k : set.getObjectIds()) {
- excludeObjectsBF.set(k);
- }
- }
-
- int count = 0; // # of processed objects in the stack
- int rootsToProcess = 0; // counter to report progress
-
- /* a stack of int structure */
- int size = 0; // # of elements in the stack
- int[] data = new int[10 * 1024]; // data for the stack - start with 10k
-
- /* first put all "roots" in the stack, and mark them as processed */
- for (int rootId : roots) {
- if (!bits[rootId]) {
- /* start stack.push() */
- if (size == data.length) {
- int[] newArr = new int[data.length << 1];
- System.arraycopy(data, 0, newArr, 0, data.length);
- data = newArr;
- }
- data[size++] = rootId;
- /* end stack.push() */
-
- bits[rootId] = true; // mark the object
- count++;
-
- rootsToProcess++;
- }
- }
-
- /* now do the real marking */
- progressListener.beginTask(Messages.ObjectMarker_CalculateRetainedSize, rootsToProcess);
-
- int current;
-
- while (size > 0) // loop until there are elements in the stack
- {
- /* do a stack.pop() */
- current = data[--size];
-
- /* report progress if one of the roots is processed */
- if (size <= rootsToProcess) {
- rootsToProcess--;
- progressListener.worked(1);
- if (progressListener.isCanceled()) throw new IProgressListener.OperationCanceledException();
- }
-
- for (int child : outbound.get(current)) {
- if (!bits[child]) // already visited?
- {
- if (!refersOnlyThroughExcluded(current, child, excludeSets, excludeObjectsBF, snapshot)) {
- /* start stack.push() */
- if (size == data.length) {
- int[] newArr = new int[data.length << 1];
- System.arraycopy(data, 0, newArr, 0, data.length);
- data = newArr;
- }
- data[size++] = child;
- /* end stack.push() */
-
- bits[child] = true; // mark the object
- count++;
- }
- }
- }
- }
-
- progressListener.done();
-
- return count;
- }
-
- public void markMultiThreaded(int numberOfThreads) throws InterruptedException {
- IntStack rootsStack = new IntStack(roots.length);
-
- for (int rootId : roots) {
- if (!bits[rootId]) {
- rootsStack.push(rootId);
- bits[rootId] = true;
- }
- }
-
- progressListener.beginTask(Messages.ObjectMarker_CalculateRetainedSize,
- rootsStack.size());
-
- // create and start as much marker threads as specified
- DfsThread[] dfsthreads = new DfsThread[numberOfThreads];
- Thread[] threads = new Thread[numberOfThreads];
-
- for (int i = 0; i < numberOfThreads; i++) {
- DfsThread dfsthread = new DfsThread(rootsStack);
- dfsthreads[i] = dfsthread;
- Thread thread = new Thread(dfsthread, "ObjectMarkerThread-" + (i + 1));//$NON-NLS-1$
- thread.start();
- threads[i] = thread;
- }
-
- // wait for all the threads to finish
- for (int i = 0; i < numberOfThreads; i++) {
- threads[i].join();
- }
-
- if (progressListener.isCanceled()) return;
-
- progressListener.done();
- }
-
- public class DfsThread implements Runnable {
-
- int size = 0;
- int[] data = new int[10 * 1024]; // start with 10k
- IntStack rootsStack;
-
- public DfsThread(IntStack roots) {
- this.rootsStack = roots;
- }
-
- public void run() {
- while (true) {
- synchronized (rootsStack) {
- progressListener.worked(1);
- if (progressListener.isCanceled()) return;
-
- if (rootsStack.size() > 0) // still some roots are not
- // processed
- {
- data[0] = rootsStack.pop();
- size = 1;
- } else
- // the work is done
- {
- break;
- }
- }
-
- int current;
-
- while (size > 0) {
- /* start stack.pop() */
- current = data[--size];
- /* end stack.pop */
-
- for (int child : outbound.get(current)) {
- /*
- * No synchronization here. It costs a lot of
- * performance It is possible that some bits are marked
- * more than once, but this is not a problem
- */
- if (!bits[child]) {
- bits[child] = true;
- // stack.push(child);
- /* start stack.push() */
- if (size == data.length) {
- int[] newArr = new int[data.length << 1];
- System.arraycopy(data, 0, newArr, 0, data.length);
- data = newArr;
- }
- data[size++] = child;
- /* end stack.push() */
- }
- }
- } // end of processing one GC root
- }
- }
- }
-
- private boolean refersOnlyThroughExcluded(int referrerId, int referentId,
- ExcludedReferencesDescriptor[] excludeSets, BitField excludeObjectsBF, ISnapshot snapshot)
- throws SnapshotException {
- if (!excludeObjectsBF.get(referrerId)) return false;
-
- IObject referrerObject = snapshot.getObject(referrerId);
- Set<String> excludeFields = null;
- for (ExcludedReferencesDescriptor set : excludeSets) {
- if (set.contains(referrerId)) {
- excludeFields = set.getFields();
- break;
- }
- }
- if (excludeFields == null) return true; // treat null as all fields
-
- long referentAddr = snapshot.mapIdToAddress(referentId);
-
- List<NamedReference> refs = referrerObject.getOutboundReferences();
- for (NamedReference reference : refs) {
- if (referentAddr == reference.getObjectAddress() && !excludeFields.contains(
- reference.getName())) {
- return false;
- }
- }
- return true;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/snapshot/PathsFromGCRootsTreeBuilder.java b/src/main/java/org/eclipse/mat/parser/internal/snapshot/PathsFromGCRootsTreeBuilder.java
deleted file mode 100644
index f2f20bd..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/snapshot/PathsFromGCRootsTreeBuilder.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal.snapshot;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import org.eclipse.mat.snapshot.PathsFromGCRootsTree;
-
-public class PathsFromGCRootsTreeBuilder {
- private int ownId;
- private ArrayList<Integer> objectIds = new ArrayList<Integer>();
- private HashMap<Integer, PathsFromGCRootsTreeBuilder> objectInboundReferers;
-
- public PathsFromGCRootsTreeBuilder(int ownId) {
- this.ownId = ownId;
- objectInboundReferers = new HashMap<Integer, PathsFromGCRootsTreeBuilder>();
- }
-
- public HashMap<Integer, PathsFromGCRootsTreeBuilder> getObjectReferers() {
- return objectInboundReferers;
- }
-
- public PathsFromGCRootsTree toPathsFromGCRootsTree() {
- HashMap<Integer, PathsFromGCRootsTree> data =
- new HashMap<Integer, PathsFromGCRootsTree>(objectInboundReferers.size());
- for (Map.Entry<Integer, PathsFromGCRootsTreeBuilder> entry : objectInboundReferers.entrySet()) {
- data.put(entry.getKey(), entry.getValue().toPathsFromGCRootsTree());
- }
- int[] children = new int[objectIds.size()];
- for (int i = 0; i < children.length; i++) {
- children[i] = objectIds.get(i);
- }
- return new PathsFromGCRootsTree(ownId, data, children);
- }
-
- public int getOwnId() {
- return ownId;
- }
-
- public void addObjectReferer(PathsFromGCRootsTreeBuilder referer) {
- if (objectInboundReferers.put(referer.getOwnId(), referer) == null) {
- objectIds.add(referer.getOwnId());
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/snapshot/RetainedSizeCache.java b/src/main/java/org/eclipse/mat/parser/internal/snapshot/RetainedSizeCache.java
deleted file mode 100644
index 1dc3f54..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/snapshot/RetainedSizeCache.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal.snapshot;
-
-import java.io.BufferedInputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.NoSuchElementException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.eclipse.mat.collect.HashMapIntLong;
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.parser.model.XSnapshotInfo;
-
-public class RetainedSizeCache {
- private String filename;
- private HashMapIntLong id2size;
- private boolean isDirty = false;
-
- public RetainedSizeCache(XSnapshotInfo snapshotInfo) {
- this.filename = snapshotInfo.getPrefix() + "i2sv2.index"; //$NON-NLS-1$
- readId2Size(snapshotInfo.getPrefix());
- }
-
- public long get(int key) {
- try {
- return id2size.get(key);
- } catch (NoSuchElementException e) {
- // $JL-EXC$
- return 0;
- }
- }
-
- public void put(int key, long value) {
- id2size.put(key, value);
- isDirty = true;
- }
-
- public void close() {
- if (!isDirty) return;
-
- try {
- File file = new File(filename);
-
- DataOutputStream out = new DataOutputStream(new FileOutputStream(file));
-
- for (int key : id2size.getAllKeys()) {
- out.writeInt(key);
- out.writeLong(id2size.get(key));
- }
-
- out.close();
-
- isDirty = false;
- } catch (IOException e) {
- Logger.getLogger(RetainedSizeCache.class.getName())
- .log(Level.WARNING, Messages.RetainedSizeCache_Warning_IgnoreError.pattern, e);
- }
- }
-
- private void doRead(File file, boolean readOldFormat) {
- DataInputStream in = null;
- boolean delete = false;
-
- try {
- id2size = new HashMapIntLong((int) file.length() / 8);
-
- in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
-
- while (in.available() > 0) {
- int key = in.readInt();
- long value = in.readLong();
- if (value < 0 && readOldFormat) value = -(value - (Long.MIN_VALUE + 1));
- id2size.put(key, value);
- }
- } catch (IOException e) {
- Logger.getLogger(RetainedSizeCache.class.getName())
- .log(Level.WARNING, Messages.RetainedSizeCache_ErrorReadingRetainedSizes.pattern, e);
-
- // might have read corrupt data
- id2size.clear();
- delete = true;
- } finally {
- try {
- if (in != null) {
- in.close();
- }
- } catch (IOException ignore) {
- // $JL-EXC$
- }
- try {
- if (delete) {
- file.delete();
- }
- } catch (RuntimeException ignore) {
- // $JL-EXC$
- }
- }
- }
-
- private void readId2Size(String prefix) {
- File file = new File(filename);
- if (file.exists()) {
- doRead(file, false);
- } else {
- File legacyFile = new File(prefix + "i2s.index");//$NON-NLS-1$
- if (legacyFile.exists()) {
- doRead(legacyFile, true);
- } else {
- id2size = new HashMapIntLong();
- }
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/util/IntStack.java b/src/main/java/org/eclipse/mat/parser/internal/util/IntStack.java
deleted file mode 100644
index 04d7a77..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/util/IntStack.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal.util;
-
-public class IntStack {
- private int[] data;
- private int size;
-
- public IntStack() {
- this(16);
- }
-
- public IntStack(int capacity) {
- data = new int[capacity];
- }
-
- public final int pop() {
- return data[--size];
- }
-
- public final void push(int i) {
- if (size == data.length) {
- int[] newArr = new int[data.length << 1];
- System.arraycopy(data, 0, newArr, 0, data.length);
- data = newArr;
- }
- data[size++] = i;
- }
-
- public final int peek() {
- return data[size - 1];
- }
-
- public final int size() {
- return size;
- }
-
- public final int capacity() {
- return data.length;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/internal/util/ParserRegistry.java b/src/main/java/org/eclipse/mat/parser/internal/util/ParserRegistry.java
deleted file mode 100644
index d8102ea..0000000
--- a/src/main/java/org/eclipse/mat/parser/internal/util/ParserRegistry.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.internal.util;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-import org.eclipse.mat.parser.IIndexBuilder;
-import org.eclipse.mat.parser.IObjectReader;
-import org.eclipse.mat.snapshot.SnapshotFormat;
-
-public class ParserRegistry {
- public static final String INDEX_BUILDER = "indexBuilder";
- public static final String OBJECT_READER = "objectReader";
-
- public List<Parser> parsers = new ArrayList<Parser>();
-
- private static ParserRegistry instance = new ParserRegistry();
-
- static {
- addParser("hprof", "hprof", new String[] { "hprof", "bin" },
- new org.eclipse.mat.hprof.HprofHeapObjectReader(),
- new org.eclipse.mat.hprof.HprofIndexBuilder());
- }
-
- public static class Parser {
- private IObjectReader objectReader;
- private IIndexBuilder indexBuilder;
-
- private String id;
- private SnapshotFormat snapshotFormat;
- private Pattern[] patterns;
-
- public Parser(String id, SnapshotFormat snapshotFormat, IObjectReader objectReader,
- IIndexBuilder indexBuilder) {
- this.id = id;
- this.snapshotFormat = snapshotFormat;
-
- this.patterns = new Pattern[snapshotFormat.getFileExtensions().length];
- for (int ii = 0; ii < snapshotFormat.getFileExtensions().length; ii++) {
- patterns[ii] = Pattern.compile(
- "(.*\\.)((?i)" + snapshotFormat.getFileExtensions()[ii] + ")(\\.[0-9]*)?");
- }
- this.objectReader = objectReader;
- this.indexBuilder = indexBuilder;
- }
-
- public IObjectReader getObjectReader() {
- return this.objectReader;
- }
-
- public IIndexBuilder getIndexBuilder() {
- return this.indexBuilder;
- }
-
- public String getId() {
- return id;
- }
-
- public String getUniqueIdentifier() {
- return id;
- }
-
- public SnapshotFormat getSnapshotFormat() {
- return snapshotFormat;
- }
- }
-
- private ParserRegistry() {
-
- }
-
- public static void addParser(String id, String snapshotFormat, String[] extensions,
- IObjectReader objectReader, IIndexBuilder indexBuilder) {
- SnapshotFormat sf = new SnapshotFormat(snapshotFormat, extensions);
- Parser p = new Parser(id, sf, objectReader, indexBuilder);
- instance.parsers.add(p);
- }
-
- public static Parser lookupParser(String uniqueIdentifier) {
- for (Parser p : instance.parsers)
- if (uniqueIdentifier.equals(p.getUniqueIdentifier())) return p;
- return null;
- }
-
- public static List<Parser> matchParser(String fileName) {
- List<Parser> answer = new ArrayList<Parser>();
- for (Parser p : instance.parsers) {
- for (Pattern regex : p.patterns) {
- if (regex.matcher(fileName).matches()) {
- answer.add(p);
- // Only need to add a parser once
- break;
- }
- }
- }
- return answer;
- }
-
- public static List<Parser> allParsers() {
- return instance.parsers;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/io/BitInputStream.java b/src/main/java/org/eclipse/mat/parser/io/BitInputStream.java
deleted file mode 100644
index baf19af..0000000
--- a/src/main/java/org/eclipse/mat/parser/io/BitInputStream.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.io;
-
-import java.io.Closeable;
-import java.io.EOFException;
-import java.io.Flushable;
-import java.io.IOException;
-import java.io.InputStream;
-
-public class BitInputStream implements Flushable, Closeable {
- public final static int DEFAULT_BUFFER_SIZE = 16 * 1024;
-
- private InputStream is;
- private int current;
- private byte[] buffer;
- private int fill;
- private int pos;
- private int avail;
-
- public BitInputStream(final InputStream is) {
- this.is = is;
- this.buffer = new byte[DEFAULT_BUFFER_SIZE];
- }
-
- public void flush() {
- avail = 0;
- pos = 0;
- fill = 0;
- }
-
- public void close() throws IOException {
- is.close();
- is = null;
- buffer = null;
- }
-
- private int read() throws IOException {
- if (avail == 0) {
- avail = is.read(buffer);
- if (avail == -1) {
- avail = 0;
- throw new EOFException();
- } else {
- pos = 0;
- }
- }
-
- avail--;
- return buffer[pos++] & 0xFF;
- }
-
- private int readFromCurrent(final int len) throws IOException {
- if (len == 0) return 0;
-
- if (fill == 0) {
- current = read();
- fill = 8;
- }
-
- return current >>> (fill -= len) & (1 << len) - 1;
- }
-
- public int readBit() throws IOException {
- return readFromCurrent(1);
- }
-
- public int readInt(int len) throws IOException {
- int i, x = 0;
-
- if (len <= fill) return readFromCurrent(len);
-
- len -= fill;
- x = readFromCurrent(fill);
-
- i = len >> 3;
- while (i-- != 0) x = x << 8 | read();
-
- len &= 7;
-
- return (x << len) | readFromCurrent(len);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/io/BitOutputStream.java b/src/main/java/org/eclipse/mat/parser/io/BitOutputStream.java
deleted file mode 100644
index faac47b..0000000
--- a/src/main/java/org/eclipse/mat/parser/io/BitOutputStream.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.io;
-
-import java.io.Closeable;
-import java.io.Flushable;
-import java.io.IOException;
-import java.io.OutputStream;
-import org.eclipse.mat.hprof.Messages;
-
-public class BitOutputStream implements Flushable, Closeable {
-
- public final static int DEFAULT_BUFFER_SIZE = 16 * 1024;
-
- private OutputStream os;
- private int current;
- private byte[] buffer;
- private int free;
- private int pos;
- private int avail;
-
- final static int TEMP_BUFFER_SIZE = 128;
- private byte[] tempBuffer = new byte[TEMP_BUFFER_SIZE];
-
- public BitOutputStream(final OutputStream os) {
- this.os = os;
- this.buffer = new byte[DEFAULT_BUFFER_SIZE];
- avail = DEFAULT_BUFFER_SIZE;
- free = 8;
- }
-
- public void flush() throws IOException {
- align();
-
- os.write(buffer, 0, pos);
- pos = 0;
- avail = buffer.length;
-
- os.flush();
- }
-
- public void close() throws IOException {
- flush();
- os.close();
- os = null;
- buffer = null;
- tempBuffer = null;
- }
-
- private void write(final int b) throws IOException {
- if (avail-- == 0) {
- if (os == null) {
- avail = 0;
- throw new IOException(Messages.BitOutputStream_Error_ArrayFull.pattern);
- }
-
- if (buffer == null) {
- os.write(b);
- avail = 0;
- return;
- }
- os.write(buffer);
- avail = buffer.length - 1;
- pos = 0;
- }
-
- buffer[pos++] = (byte) b;
- }
-
- private int writeInCurrent(final int b, final int len) throws IOException {
- current |= (b & ((1 << len) - 1)) << (free -= len);
- if (free == 0) {
- write(current);
- free = 8;
- current = 0;
- }
-
- return len;
- }
-
- private int align() throws IOException {
- if (free != 8) {
- return writeInCurrent(0, free);
- } else {
- return 0;
- }
- }
-
- public int writeBit(final int bit) throws IOException {
- return writeInCurrent(bit, 1);
- }
-
- public int writeInt(int x, final int len) throws IOException {
- if (len <= free) return writeInCurrent(x, len);
-
- final int queue = (len - free) & 7, blocks = (len - free) >> 3;
- int i = blocks;
-
- if (queue != 0) {
- tempBuffer[blocks] = (byte) x;
- x >>= queue;
- }
-
- while (i-- != 0) {
- tempBuffer[i] = (byte) x;
- x >>>= 8;
- }
-
- writeInCurrent(x, free);
- for (i = 0; i < blocks; i++)
- write(tempBuffer[i]);
-
- if (queue != 0) writeInCurrent(tempBuffer[blocks], queue);
- return len;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/io/BufferedRandomAccessInputStream.java b/src/main/java/org/eclipse/mat/parser/io/BufferedRandomAccessInputStream.java
deleted file mode 100644
index d74d712..0000000
--- a/src/main/java/org/eclipse/mat/parser/io/BufferedRandomAccessInputStream.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.io;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.RandomAccessFile;
-import java.lang.ref.SoftReference;
-import org.eclipse.mat.collect.HashMapLongObject;
-
-public class BufferedRandomAccessInputStream extends InputStream {
- RandomAccessFile raf;
-
- private class Page {
- long real_pos_start;
- byte[] buffer;
- int buf_end;
-
- public Page() {
- buffer = new byte[bufsize];
- }
- }
-
- int bufsize;
- long fileLength;
- long real_pos;
- long reported_pos;
-
- HashMapLongObject<SoftReference<Page>> pages = new HashMapLongObject<SoftReference<Page>>();
-
- Page current;
-
- public BufferedRandomAccessInputStream(RandomAccessFile in) throws IOException {
- this(in, 1024);
- }
-
- public BufferedRandomAccessInputStream(RandomAccessFile in, int bufsize) throws IOException {
- this.bufsize = bufsize;
- this.raf = in;
- this.fileLength = in.length();
- }
-
- public final int read() throws IOException {
- if (reported_pos == fileLength) return -1;
-
- if (current == null || (reported_pos - current.real_pos_start) >= current.buf_end) {
- current = getPage(reported_pos);
- }
-
- return current.buffer[((int) (reported_pos++ - current.real_pos_start))] & 0xff;
- }
-
- @Override public int read(byte[] b, int off, int len) throws IOException {
- if (b == null) {
- throw new NullPointerException();
- } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off
- + len) < 0)) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return 0;
- }
-
- if (reported_pos == fileLength) return -1;
-
- int copied = 0;
-
- while (copied < len) {
- if (reported_pos == fileLength) return copied;
-
- if (current == null || (reported_pos - current.real_pos_start) >= current.buf_end) {
- current = getPage(reported_pos);
- }
-
- int buf_pos = (int) (reported_pos - current.real_pos_start);
- int length = Math.min(len - copied, current.buf_end - buf_pos);
- System.arraycopy(current.buffer, buf_pos, b, off + copied, length);
-
- reported_pos += length;
- copied += length;
- }
-
- return copied;
- }
-
- private Page getPage(long pos) throws IOException {
- long key = pos / bufsize;
-
- SoftReference<Page> r = pages.get(key);
- Page p = r == null ? null : r.get();
-
- if (p != null) return p;
-
- long page_start = key * bufsize;
-
- if (page_start != real_pos) {
- raf.seek(page_start);
- real_pos = page_start;
- }
-
- p = new Page();
-
- int n = raf.read(p.buffer);
- if (n >= 0) {
- p.real_pos_start = real_pos;
- p.buf_end = n;
- real_pos += n;
- }
-
- pages.put(key, new SoftReference<Page>(p));
-
- return p;
- }
-
- public boolean markSupported() {
- return false;
- }
-
- public void close() throws IOException {
- raf.close();
- }
-
- /**
- * @throws IOException
- */
- public void seek(long pos) throws IOException {
- reported_pos = pos;
- current = null;
- }
-
- public long getFilePointer() {
- return reported_pos;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/io/PositionInputStream.java b/src/main/java/org/eclipse/mat/parser/io/PositionInputStream.java
deleted file mode 100644
index f127b8e..0000000
--- a/src/main/java/org/eclipse/mat/parser/io/PositionInputStream.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.io;
-
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.EOFException;
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import org.eclipse.mat.hprof.Messages;
-
-public class PositionInputStream extends FilterInputStream implements DataInput {
- private final byte[] readBuffer = new byte[32];
- private long position = 0L;
-
- public PositionInputStream(InputStream in) {
- super(in);
- }
-
- public int read() throws IOException {
- int res = super.read();
- if (res != -1) position++;
- return res;
- }
-
- public int read(byte[] b, int off, int len) throws IOException {
- int res = super.read(b, off, len);
- if (res != -1) position += res;
- return res;
- }
-
- public long skip(long n) throws IOException {
- long res = super.skip(n);
- position += res;
- return res;
- }
-
- public boolean markSupported() {
- return false;
- }
-
- public void mark(int readLimit) {
- throw new UnsupportedOperationException(Messages.PositionInputStream_mark.pattern);
- }
-
- public void reset() {
- throw new UnsupportedOperationException(Messages.PositionInputStream_reset.pattern);
- }
-
- public final int skipBytes(int n) throws IOException {
- int total = 0;
- int cur = 0;
-
- while ((total < n) && ((cur = (int) skip(n - total)) > 0)) {
- total += cur;
- }
-
- return total;
- }
-
- public final int skipBytes(long n) throws IOException {
- int total = 0;
- int cur = 0;
-
- while ((total < n) && ((cur = (int) skip(n - total)) > 0)) {
- total += cur;
- }
-
- return total;
- }
-
- public final void readFully(byte b[]) throws IOException {
- readFully(b, 0, b.length);
- }
-
- public final void readFully(byte b[], int off, int len) throws IOException {
- int n = 0;
- while (n < len) {
- int count = read(b, off + n, len - n);
- if (count < 0) throw new EOFException();
- n += count;
- }
- }
-
- public long position() {
- return position;
- }
-
- public void seek(long pos) throws IOException {
- if (in instanceof BufferedRandomAccessInputStream) {
- position = pos;
- ((BufferedRandomAccessInputStream) in).seek(pos);
- } else if (in instanceof SimpleBufferedRandomAccessInputStream) {
- position = pos;
- ((SimpleBufferedRandomAccessInputStream) in).seek(pos);
- } else {
- throw new UnsupportedOperationException(Messages.PositionInputStream_seek.pattern);
- }
- }
-
- // //////////////////////////////////////////////////////////////
- // DataInput implementations
- // //////////////////////////////////////////////////////////////
-
- public final int readUnsignedByte() throws IOException {
- int ch = in.read();
- if (ch < 0) throw new EOFException();
- position++;
- return ch;
- }
-
- public final int readInt() throws IOException {
- readFully(readBuffer, 0, 4);
- return readInt(readBuffer, 0);
- }
-
- public final long readLong() throws IOException {
- readFully(readBuffer, 0, 8);
- return readLong(readBuffer, 0);
- }
-
- public boolean readBoolean() throws IOException {
- int ch = in.read();
- if (ch < 0) throw new EOFException();
- position++;
- return (ch != 0);
- }
-
- public byte readByte() throws IOException {
- int ch = in.read();
- if (ch < 0) throw new EOFException();
- position++;
- return (byte) (ch);
- }
-
- public char readChar() throws IOException {
- int ch1 = in.read();
- int ch2 = in.read();
- if ((ch1 | ch2) < 0) throw new EOFException();
- position += 2;
- return (char) ((ch1 << 8) + (ch2 << 0));
- }
-
- public double readDouble() throws IOException {
- return Double.longBitsToDouble(readLong());
- }
-
- public float readFloat() throws IOException {
- return Float.intBitsToFloat(readInt());
- }
-
- public String readLine() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- public short readShort() throws IOException {
- int ch1 = in.read();
- int ch2 = in.read();
- if ((ch1 | ch2) < 0) throw new EOFException();
- position += 2;
- return (short) ((ch1 << 8) + (ch2 << 0));
- }
-
- public String readUTF() throws IOException {
- return DataInputStream.readUTF(this);
- }
-
- public int readUnsignedShort() throws IOException {
- int ch1 = in.read();
- int ch2 = in.read();
- if ((ch1 | ch2) < 0) throw new EOFException();
- position += 2;
- return (ch1 << 8) + (ch2 << 0);
- }
-
- // //////////////////////////////////////////////////////////////
- // additions
- // //////////////////////////////////////////////////////////////
-
- public int readIntArray(int[] a) throws IOException {
- int len = a.length * 4;
- byte[] b = len > readBuffer.length ? new byte[len] : readBuffer;
-
- if (read(b, 0, len) != len) throw new IOException();
-
- for (int ii = 0; ii < a.length; ii++)
- a[ii] = readInt(b, ii * 4);
-
- return a.length;
- }
-
- private static final int readInt(byte[] b, int offset) throws IOException {
- int ch1 = b[offset] & 0xff;
- int ch2 = b[offset + 1] & 0xff;
- int ch3 = b[offset + 2] & 0xff;
- int ch4 = b[offset + 3] & 0xff;
- if ((ch1 | ch2 | ch3 | ch4) < 0) throw new EOFException();
- return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
- }
-
- public int readLongArray(long[] a) throws IOException {
- int len = a.length * 8;
- byte[] b = len > readBuffer.length ? new byte[len] : readBuffer;
-
- if (read(b, 0, len) != len) throw new IOException();
-
- for (int ii = 0; ii < a.length; ii++)
- a[ii] = readLong(b, ii * 8);
-
- return a.length;
- }
-
- private static final long readLong(byte[] b, int offset) {
- return (((long) b[offset] << 56) //
- + ((long) (b[offset + 1] & 255) << 48) //
- + ((long) (b[offset + 2] & 255) << 40) //
- + ((long) (b[offset + 3] & 255) << 32) //
- + ((long) (b[offset + 4] & 255) << 24) //
- + ((b[offset + 5] & 255) << 16) //
- + ((b[offset + 6] & 255) << 8) //
- + ((b[offset + 7] & 255) << 0));
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/io/SimpleBufferedRandomAccessInputStream.java b/src/main/java/org/eclipse/mat/parser/io/SimpleBufferedRandomAccessInputStream.java
deleted file mode 100644
index 0dd7f9e..0000000
--- a/src/main/java/org/eclipse/mat/parser/io/SimpleBufferedRandomAccessInputStream.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.io;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.RandomAccessFile;
-
-public class SimpleBufferedRandomAccessInputStream extends InputStream {
- private byte[] readBuffer = new byte[32];
-
- private RandomAccessFile raf;
- private byte[] buffer;
- private int buf_end;
- private int buf_pos;
- private long real_pos;
-
- public SimpleBufferedRandomAccessInputStream(RandomAccessFile in) throws IOException {
- this(in, 2 * 4096);
- }
-
- public SimpleBufferedRandomAccessInputStream(RandomAccessFile in, int bufsize)
- throws IOException {
- this.raf = in;
- invalidate();
- buffer = new byte[bufsize];
- }
-
- private void invalidate() throws IOException {
- buf_end = 0;
- buf_pos = 0;
- real_pos = raf.getFilePointer();
- }
-
- public final int read() throws IOException {
- if (buf_pos >= buf_end) {
- if (fillBuffer() < 0) return -1;
- }
- if (buf_end == 0) {
- return -1;
- } else {
- return buffer[buf_pos++] & 0xff;
- }
- }
-
- @Override public int read(byte[] b, int off, int len) throws IOException {
- if (len == 0) {
- return 0;
- }
-
- if (buf_pos >= buf_end) {
- if (fillBuffer() < 0) return -1;
- }
-
- if (buf_end == 0) return -1;
-
- int copied = 0;
-
- while (copied < len) {
- if (buf_pos >= buf_end) {
- if (fillBuffer() < 0) return copied;
- }
-
- int length = Math.min(len - copied, buf_end - buf_pos);
- System.arraycopy(buffer, buf_pos, b, off + copied, length);
- buf_pos += length;
- copied += length;
- }
-
- return copied;
- }
-
- private int fillBuffer() throws IOException {
- int n = raf.read(buffer);
- if (n >= 0) {
- real_pos += n;
- buf_end = n;
- buf_pos = 0;
- }
- return n;
- }
-
- public boolean markSupported() {
- return false;
- }
-
- public void close() throws IOException {
- raf.close();
- buffer = null;
- }
-
- public void seek(long pos) throws IOException {
- int n = (int) (real_pos - pos);
- if (n >= 0 && n <= buf_end) {
- buf_pos = buf_end - n;
- } else {
- raf.seek(pos);
- invalidate();
- }
- }
-
- public long getFilePointer() {
- return (real_pos - buf_end + buf_pos);
- }
-
- public final int readInt() throws IOException {
- if (buf_pos + 4 < buf_end) {
- int a = readInt(buffer, buf_pos);
- buf_pos += 4;
- return a;
- } else {
- if (read(readBuffer, 0, 4) != 4) throw new IOException();
- return readInt(readBuffer, 0);
- }
- }
-
- public final long readLong() throws IOException {
- if (buf_pos + 8 < buf_end) {
- long a = readLong(buffer, buf_pos);
- buf_pos += 8;
- return a;
- } else {
- if (read(readBuffer, 0, 8) != 8) throw new IOException();
- return readLong(readBuffer, 0);
- }
- }
-
- public int readIntArray(int[] a) throws IOException {
- int offset = 0, len = a.length * 4;
- byte[] b = null;
- if (buf_pos + len < buf_end) {
- b = buffer;
- offset = buf_pos;
- buf_pos += len;
- } else {
- b = len > readBuffer.length ? new byte[len] : readBuffer;
- if (read(b, 0, len) != len) throw new IOException();
- }
-
- for (int ii = 0; ii < a.length; ii++)
- a[ii] = readInt(b, offset + (ii * 4));
-
- return a.length;
- }
-
- private static final int readInt(byte[] b, int offset) throws IOException {
- int ch1 = b[offset] & 0xff;
- int ch2 = b[offset + 1] & 0xff;
- int ch3 = b[offset + 2] & 0xff;
- int ch4 = b[offset + 3] & 0xff;
- if ((ch1 | ch2 | ch3 | ch4) < 0) throw new EOFException();
- return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
- }
-
- public int readLongArray(long[] a) throws IOException {
- int offset = 0, len = a.length * 8;
- byte[] b = null;
- if (buf_pos + len < buf_end) {
- b = buffer;
- offset = buf_pos;
- buf_pos += len;
- } else {
- b = len > readBuffer.length ? new byte[len] : readBuffer;
- if (read(b, 0, len) != len) throw new IOException();
- }
-
- for (int ii = 0; ii < a.length; ii++)
- a[ii] = readLong(b, offset + (ii * 8));
-
- return a.length;
- }
-
- private static final long readLong(byte[] b, int offset) {
- return (((long) b[offset] << 56) //
- + ((long) (b[offset + 1] & 255) << 48) //
- + ((long) (b[offset + 2] & 255) << 40) //
- + ((long) (b[offset + 3] & 255) << 32) //
- + ((long) (b[offset + 4] & 255) << 24) //
- + ((b[offset + 5] & 255) << 16) //
- + ((b[offset + 6] & 255) << 8) //
- + ((b[offset + 7] & 255) << 0));
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/model/AbstractArrayImpl.java b/src/main/java/org/eclipse/mat/parser/model/AbstractArrayImpl.java
deleted file mode 100644
index 7110287..0000000
--- a/src/main/java/org/eclipse/mat/parser/model/AbstractArrayImpl.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.model;
-
-import org.eclipse.mat.snapshot.model.IArray;
-
-/**
- * @noextend
- */
-public abstract class AbstractArrayImpl extends AbstractObjectImpl implements IArray {
- private static final long serialVersionUID = 2L;
-
- protected int length;
-
- private Object info;
-
- public AbstractArrayImpl(int objectId, long address, ClassImpl classInstance, int length) {
- super(objectId, address, classInstance);
- this.length = length;
- }
-
- public Object getInfo() {
- return info;
- }
-
- public void setInfo(Object content) {
- this.info = content;
- }
-
- public int getLength() {
- return length;
- }
-
- public void setLength(int i) {
- length = i;
- }
-
- protected StringBuffer appendFields(StringBuffer buf) {
- return super.appendFields(buf).append(";length=").append(length);//$NON-NLS-1$
- }
-
- public String getTechnicalName() {
- StringBuilder builder = new StringBuilder(256);
- String name = getClazz().getName();
-
- int p = name.indexOf('[');
- if (p < 0) {
- builder.append(name);
- } else {
- builder.append(name.subSequence(0, p + 1)).append(getLength()).append(name.substring(p + 1));
- }
-
- builder.append(" @ 0x");//$NON-NLS-1$
- builder.append(Long.toHexString(getObjectAddress()));
- return builder.toString();
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/model/AbstractObjectImpl.java b/src/main/java/org/eclipse/mat/parser/model/AbstractObjectImpl.java
deleted file mode 100644
index 37a6e6e..0000000
--- a/src/main/java/org/eclipse/mat/parser/model/AbstractObjectImpl.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.model;
-
-import java.io.Serializable;
-import java.util.Comparator;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.ArrayLong;
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.parser.internal.SnapshotImpl;
-import org.eclipse.mat.snapshot.ISnapshot;
-import org.eclipse.mat.snapshot.model.Field;
-import org.eclipse.mat.snapshot.model.GCRootInfo;
-import org.eclipse.mat.snapshot.model.IObject;
-import org.eclipse.mat.snapshot.model.ObjectReference;
-import org.eclipse.mat.snapshot.registry.ClassSpecificNameResolverRegistry;
-import org.eclipse.mat.util.MessageUtil;
-
-/**
- * @noextend
- */
-public abstract class AbstractObjectImpl implements IObject, Serializable {
- private static final long serialVersionUID = 2451875423035843852L;
-
- protected transient SnapshotImpl source;
- protected ClassImpl classInstance;
- private long address;
- private int objectId;
-
- public AbstractObjectImpl(int objectId, long address, ClassImpl classInstance) {
- this.objectId = objectId;
- this.address = address;
- this.classInstance = classInstance;
- }
-
- public long getObjectAddress() {
- return address;
- }
-
- public int getObjectId() {
- return objectId;
- }
-
- public void setObjectAddress(long address) {
- this.address = address;
- }
-
- public void setObjectId(int objectId) {
- this.objectId = objectId;
- }
-
- public ClassImpl getClazz() {
- return classInstance;
- }
-
- public long getClassAddress() {
- return classInstance.getObjectAddress();
- }
-
- public int getClassId() {
- return classInstance.getObjectId();
- }
-
- public void setClassInstance(ClassImpl classInstance) {
- this.classInstance = classInstance;
- }
-
- public void setSnapshot(ISnapshot dump) {
- this.source = (SnapshotImpl) dump;
- }
-
- public ISnapshot getSnapshot() {
- return this.source;
- }
-
- abstract public int getUsedHeapSize();
-
- public long getRetainedHeapSize() {
- try {
- return source.getRetainedHeapSize(getObjectId());
- } catch (SnapshotException e) {
- throw new RuntimeException(e);
- }
- }
-
- public abstract ArrayLong getReferences();
-
- @Override public String toString() {
- StringBuffer s = new StringBuffer(256);
- s.append(this.getClazz().getName());
- s.append(" [");//$NON-NLS-1$
- appendFields(s);
- s.append("]");//$NON-NLS-1$
- return s.toString();
- }
-
- protected StringBuffer appendFields(StringBuffer buf) {
- return buf.append("id=0x").append(Long.toHexString(getObjectAddress()));//$NON-NLS-1$
- }
-
- public String getClassSpecificName() {
- return ClassSpecificNameResolverRegistry.resolve(this);
- }
-
- public String getTechnicalName() {
- StringBuilder builder = new StringBuilder(256);
- builder.append(getClazz().getName());
- builder.append(" @ 0x");//$NON-NLS-1$
- builder.append(Long.toHexString(getObjectAddress()));
- return builder.toString();
- }
-
- public String getDisplayName() {
- String label = getClassSpecificName();
- if (label == null) {
- return getTechnicalName();
- } else {
- StringBuilder s =
- new StringBuilder(256).append(getTechnicalName()).append(" "); //$NON-NLS-1$
- if (label.length() <= 256) {
- s.append(label);
- } else {
- s.append(label.substring(0, 256));
- s.append("...");//$NON-NLS-1$
- }
- return s.toString();
- }
- }
-
- // If the name is in the form <FIELD>{.<FIELD>}
- // the fields are transiently followed
- public final Object resolveValue(String name) throws SnapshotException {
- int p = name.indexOf('.');
- String n = p < 0 ? name : name.substring(0, p);
- Field f = internalGetField(n);
- if (f == null || f.getValue() == null) return null;
- if (p < 0) {
- Object answer = f.getValue();
- if (answer instanceof ObjectReference) answer = ((ObjectReference) answer).getObject();
- return answer;
- }
-
- if (!(f.getValue() instanceof ObjectReference)) {
- String msg =
- MessageUtil.format(Messages.AbstractObjectImpl_Error_FieldIsNotReference, new Object[] {
- n, getTechnicalName(), name.substring(p + 1)
- });
- throw new SnapshotException(msg);
- }
-
- ObjectReference ref = (ObjectReference) f.getValue();
- if (ref == null) return null;
-
- int objectId = ref.getObjectId();
- if (objectId < 0) {
- String msg =
- MessageUtil.format(Messages.AbstractObjectImpl_Error_FieldContainsIllegalReference,
- new Object[] { n, getTechnicalName(), Long.toHexString(ref.getObjectAddress()) });
- throw new SnapshotException(msg);
- }
-
- return this.source.getObject(objectId).resolveValue(name.substring(p + 1));
- }
-
- protected abstract Field internalGetField(String name);
-
- public GCRootInfo[] getGCRootInfo() throws SnapshotException {
- return source.getGCRootInfo(getObjectId());
- }
-
- @Override public boolean equals(Object obj) {
- return obj instanceof IObject && this.objectId == ((IObject) obj).getObjectId();
- }
-
- @Override public int hashCode() {
- return this.objectId;
- }
-
- public static Comparator<AbstractObjectImpl> getComparatorForTechnicalName() {
- return null;
- }
-
- public static Comparator<AbstractObjectImpl> getComparatorForClassSpecificName() {
- return null;
- }
-
- public static Comparator<AbstractObjectImpl> getComparatorForUsedHeapSize() {
- return null;
- }
-
- // //////////////////////////////////////////////////////////////
- // internal helpers
- // //////////////////////////////////////////////////////////////
-
- /* Helper for the net size calculation */
- protected static int alignUpTo8(int n) {
- return n % 8 == 0 ? n : n + 8 - n % 8;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/model/ClassImpl.java b/src/main/java/org/eclipse/mat/parser/model/ClassImpl.java
deleted file mode 100644
index f9c37c9..0000000
--- a/src/main/java/org/eclipse/mat/parser/model/ClassImpl.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.model;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.ArrayInt;
-import org.eclipse.mat.collect.ArrayLong;
-import org.eclipse.mat.snapshot.ISnapshot;
-import org.eclipse.mat.snapshot.model.Field;
-import org.eclipse.mat.snapshot.model.FieldDescriptor;
-import org.eclipse.mat.snapshot.model.IClass;
-import org.eclipse.mat.snapshot.model.NamedReference;
-import org.eclipse.mat.snapshot.model.ObjectReference;
-import org.eclipse.mat.snapshot.model.PseudoReference;
-import org.eclipse.mat.util.IProgressListener;
-import org.eclipse.mat.util.VoidProgressListener;
-
-/**
- * @noextend
- */
-public class ClassImpl extends AbstractObjectImpl implements IClass, Comparable<ClassImpl> {
- private static final long serialVersionUID = 22L;
-
- public static final String JAVA_LANG_CLASS = IClass.JAVA_LANG_CLASS;
-
- protected String name;
- protected int superClassId = -1;
- protected long superClassAddress;
- protected int classLoaderId = -1;
- protected long classLoaderAddress;
- protected Field[] staticFields;
- protected FieldDescriptor[] fields;
- protected int usedHeapSize;
- protected int instanceSize;
- protected int instanceCount;
- protected long totalSize;
- protected boolean isArrayType;
-
- private List<IClass> subClasses;
-
- private Serializable cacheEntry;
-
- public ClassImpl(long address, String name, long superId, long loaderId, Field[] staticFields,
- FieldDescriptor[] fields) {
- super(-1, address, null);
-
- this.name = name;
- this.superClassAddress = superId;
- this.classLoaderAddress = loaderId;
- this.staticFields = staticFields;
- this.fields = fields;
- this.instanceSize = -1;
-
- this.totalSize = 0;
- this.isArrayType = name.endsWith("[]");//$NON-NLS-1$
- }
-
- public Serializable getCacheEntry() {
- return cacheEntry;
- }
-
- public void setCacheEntry(Serializable cacheEntry) {
- this.cacheEntry = cacheEntry;
- }
-
- public void setSuperClassIndex(int superClassIndex) {
- this.superClassId = superClassIndex;
- }
-
- public void setClassLoaderIndex(int classLoaderIndex) {
- this.classLoaderId = classLoaderIndex;
- }
-
- public int[] getObjectIds() throws UnsupportedOperationException, SnapshotException {
- try {
- return source.getIndexManager().c2objects().getObjectsOf(this.cacheEntry);
- } catch (IOException e) {
- throw new SnapshotException(e);
- }
- }
-
- public long getRetainedHeapSizeOfObjects(boolean calculateIfNotAvailable, boolean approximation,
- IProgressListener listener) throws SnapshotException {
- long answer = this.source.getRetainedSizeCache().get(getObjectId());
-
- if (answer > 0 || !calculateIfNotAvailable) return answer;
-
- if (answer < 0 && approximation) return answer;
-
- if (listener == null) listener = new VoidProgressListener();
-
- ArrayInt ids = new ArrayInt();
- ids.add(getObjectId());
- ids.addAll(getObjectIds());
-
- int[] retainedSet;
- long retainedSize = 0;
-
- if (!approximation) {
- retainedSet = source.getRetainedSet(ids.toArray(), listener);
- if (listener.isCanceled()) return 0;
- retainedSize = source.getHeapSize(retainedSet);
- } else {
- retainedSize = source.getMinRetainedSize(ids.toArray(), listener);
- if (listener.isCanceled()) return 0;
- }
-
- if (approximation) retainedSize = -retainedSize;
-
- this.source.getRetainedSizeCache().put(getObjectId(), retainedSize);
- return retainedSize;
- }
-
- @Override public int getUsedHeapSize() {
- return usedHeapSize;
- }
-
- public ArrayLong getReferences() {
- ArrayLong answer = new ArrayLong(staticFields.length);
-
- answer.add(classInstance.getObjectAddress());
- if (superClassAddress != 0) answer.add(superClassAddress);
- answer.add(classLoaderAddress);
-
- for (int ii = 0; ii < staticFields.length; ii++) {
- if (staticFields[ii].getValue() instanceof ObjectReference) {
- ObjectReference ref = (ObjectReference) staticFields[ii].getValue();
- answer.add(ref.getObjectAddress());
- }
- }
-
- return answer;
- }
-
- public List<NamedReference> getOutboundReferences() {
- List<NamedReference> answer = new LinkedList<NamedReference>();
- answer.add(
- new PseudoReference(source, classInstance.getObjectAddress(), "<class>"));//$NON-NLS-1$
- if (superClassAddress != 0) {
- answer.add(new PseudoReference(source, superClassAddress, "<super>"));//$NON-NLS-1$
- }
- answer.add(new PseudoReference(source, classLoaderAddress, "<classloader>"));//$NON-NLS-1$
-
- for (int ii = 0; ii < staticFields.length; ii++) {
- if (staticFields[ii].getValue() instanceof ObjectReference) {
- ObjectReference ref = (ObjectReference) staticFields[ii].getValue();
- String fieldName = staticFields[ii].getName();
- if (fieldName.startsWith("<")) //$NON-NLS-1$
- {
- answer.add(new PseudoReference(source, ref.getObjectAddress(), fieldName));
- } else {
- answer.add(new NamedReference(source, ref.getObjectAddress(), fieldName));
- }
- }
- }
-
- return answer;
- }
-
- public long getClassLoaderAddress() {
- return classLoaderAddress;
- }
-
- public void setClassLoaderAddress(long address) {
- this.classLoaderAddress = address;
- }
-
- public List<FieldDescriptor> getFieldDescriptors() {
- return Arrays.asList(fields);
- }
-
- public int getNumberOfObjects() {
- return instanceCount;
- }
-
- public int getHeapSizePerInstance() {
- return instanceSize;
- }
-
- public void setHeapSizePerInstance(int size) {
- instanceSize = size;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<Field> getStaticFields() {
- return Arrays.asList(staticFields);
- }
-
- public long getSuperClassAddress() {
- return superClassAddress;
- }
-
- public int getSuperClassId() {
- return superClassId;
- }
-
- public ClassImpl getSuperClass() {
- try {
- return superClassAddress != 0 ? (ClassImpl) this.source.getObject(superClassId) : null;
- } catch (SnapshotException e) {
- throw new RuntimeException(e);
- }
- }
-
- public long getTotalSize() {
- return totalSize;
- }
-
- public boolean hasSuperClass() {
- return this.superClassAddress != 0;
- }
-
- public int compareTo(ClassImpl other) {
- final long myAddress = getObjectAddress();
- final long otherAddress = other.getObjectAddress();
- return myAddress > otherAddress ? 1 : myAddress == otherAddress ? 0 : -1;
- }
-
- public void addInstance(int usedHeapSize) {
- this.instanceCount++;
- this.totalSize += usedHeapSize;
- }
-
- public void removeInstance(int heapSizePerInstance) {
- this.instanceCount--;
- this.totalSize -= heapSizePerInstance;
- }
-
- @SuppressWarnings("unchecked") public List<IClass> getSubclasses() {
- return subClasses != null ? subClasses : Collections.EMPTY_LIST;
- }
-
- public List<IClass> getAllSubclasses() {
- if (subClasses == null || subClasses.isEmpty()) return new ArrayList<IClass>();
-
- List<IClass> answer = new ArrayList<IClass>(subClasses.size() * 2);
- answer.addAll(this.subClasses);
- for (IClass subClass : this.subClasses)
- answer.addAll(subClass.getAllSubclasses());
- return answer;
- }
-
- @Override protected StringBuffer appendFields(StringBuffer buf) {
- return super.appendFields(buf).append(";name=").append(getName());//$NON-NLS-1$
- }
-
- public boolean isArrayType() {
- return isArrayType;
- }
-
- public String getTechnicalName() {
- StringBuilder builder = new StringBuilder(256);
- builder.append("class ");//$NON-NLS-1$
- builder.append(getName());
- builder.append(" @ 0x");//$NON-NLS-1$
- builder.append(Long.toHexString(getObjectAddress()));
- return builder.toString();
- }
-
- @Override protected Field internalGetField(String name) {
- for (Field f : staticFields)
- if (f.getName().equals(name)) return f;
- return null;
- }
-
- public int getClassLoaderId() {
- return classLoaderId;
- }
-
- public void addSubClass(ClassImpl clazz) {
- if (subClasses == null) subClasses = new ArrayList<IClass>();
- subClasses.add(clazz);
- }
-
- public void removeSubClass(ClassImpl clazz) {
- subClasses.remove(clazz);
- }
-
- public void setUsedHeapSize(int usedHeapSize) {
- this.usedHeapSize = usedHeapSize;
- }
-
- public boolean doesExtend(String className) throws SnapshotException {
- if (className.equals(this.name)) return true;
-
- return (hasSuperClass() && source != null) ? ((ClassImpl) source.getObject(
- this.superClassId)).doesExtend(className) : false;
- }
-
- @Override public void setSnapshot(ISnapshot dump) {
- super.setSnapshot(dump);
-
- // object reference need (for convenience) a reference to the snapshot
- // inject after restoring class objects
-
- for (Field f : this.staticFields) {
- if (f.getValue() instanceof ObjectReference) {
- ObjectReference ref = (ObjectReference) f.getValue();
- f.setValue(new ObjectReference(dump, ref.getObjectAddress()));
- }
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/model/ClassLoaderImpl.java b/src/main/java/org/eclipse/mat/parser/model/ClassLoaderImpl.java
deleted file mode 100644
index 9302b89..0000000
--- a/src/main/java/org/eclipse/mat/parser/model/ClassLoaderImpl.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.model;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.ArrayInt;
-import org.eclipse.mat.parser.internal.SnapshotImpl;
-import org.eclipse.mat.snapshot.ISnapshot;
-import org.eclipse.mat.snapshot.model.Field;
-import org.eclipse.mat.snapshot.model.IClass;
-import org.eclipse.mat.snapshot.model.IClassLoader;
-import org.eclipse.mat.snapshot.registry.ClassSpecificNameResolverRegistry;
-import org.eclipse.mat.util.IProgressListener;
-import org.eclipse.mat.util.VoidProgressListener;
-
-/**
- * @noextend
- */
-public class ClassLoaderImpl extends InstanceImpl implements IClassLoader {
- private static final long serialVersionUID = 1L;
-
- public static final String NO_LABEL = "__none__";//$NON-NLS-1$
-
- private volatile transient List<IClass> definedClasses = null;
-
- public ClassLoaderImpl(int objectId, long address, ClassImpl clazz, List<Field> fields) {
- super(objectId, address, clazz, fields);
- }
-
- @Override protected synchronized void readFully() {
- // check for the special case of the system class loader
- if (getObjectAddress() == 0) {
- setFields(new ArrayList<Field>());
- } else {
- super.readFully();
- }
- }
-
- @Override public String getClassSpecificName() {
- String label = source.getClassLoaderLabel(getObjectId());
-
- if (NO_LABEL.equals(label)) {
- label = ClassSpecificNameResolverRegistry.resolve(this);
- if (label != null) source.setClassLoaderLabel(getObjectId(), label);
- }
-
- return label;
- }
-
- @SuppressWarnings("null") public List<IClass> getDefinedClasses() throws SnapshotException {
- List<IClass> result = definedClasses;
- if (result == null) {
- synchronized (this) {
- if (result == null) {
- definedClasses = result = doGetDefinedClasses(source, getObjectId());
- }
- }
- }
- return result;
- }
-
- public long getRetainedHeapSizeOfObjects(boolean calculateIfNotAvailable,
- boolean calculateMinRetainedSize, IProgressListener listener) throws SnapshotException {
- return doGetRetainedHeapSizeOfObjects(source, getObjectId(), calculateIfNotAvailable,
- calculateMinRetainedSize, listener);
- }
-
- public static final List<IClass> doGetDefinedClasses(ISnapshot dump, int classLoaderId)
- throws SnapshotException {
- List<IClass> answer = new ArrayList<IClass>();
- for (IClass clasz : dump.getClasses()) {
- if (clasz.getClassLoaderId() == classLoaderId) answer.add(clasz);
- }
- return answer;
- }
-
- public static final long doGetRetainedHeapSizeOfObjects(ISnapshot dump, int classLoaderId,
- boolean calculateIfNotAvailable, boolean calculateMinRetainedSize, IProgressListener listener)
- throws SnapshotException {
- long answer = ((SnapshotImpl) dump).getRetainedSizeCache().get(classLoaderId);
-
- if (answer > 0 || !calculateIfNotAvailable) return answer;
-
- if (answer < 0 && calculateMinRetainedSize) return answer;
-
- if (listener == null) listener = new VoidProgressListener();
-
- ArrayInt objectIds = new ArrayInt();
- objectIds.add(classLoaderId);
- for (IClass clasz : doGetDefinedClasses(dump, classLoaderId)) {
- objectIds.add(clasz.getObjectId());
- objectIds.addAll(clasz.getObjectIds());
- }
-
- int[] retainedSet;
- long retainedSize = 0;
-
- if (!calculateMinRetainedSize) {
- retainedSet = dump.getRetainedSet(objectIds.toArray(), listener);
- if (listener.isCanceled()) return 0;
- retainedSize = dump.getHeapSize(retainedSet);
- } else {
- retainedSize = dump.getMinRetainedSize(objectIds.toArray(), listener);
- if (listener.isCanceled()) return 0;
- }
-
- if (calculateMinRetainedSize) retainedSize = -retainedSize;
-
- ((SnapshotImpl) dump).getRetainedSizeCache().put(classLoaderId, retainedSize);
- return retainedSize;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/model/InstanceImpl.java b/src/main/java/org/eclipse/mat/parser/model/InstanceImpl.java
deleted file mode 100644
index 2ae85d6..0000000
--- a/src/main/java/org/eclipse/mat/parser/model/InstanceImpl.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.model;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.ArrayLong;
-import org.eclipse.mat.collect.HashMapIntObject;
-import org.eclipse.mat.collect.IteratorInt;
-import org.eclipse.mat.snapshot.model.Field;
-import org.eclipse.mat.snapshot.model.GCRootInfo;
-import org.eclipse.mat.snapshot.model.IInstance;
-import org.eclipse.mat.snapshot.model.NamedReference;
-import org.eclipse.mat.snapshot.model.ObjectReference;
-import org.eclipse.mat.snapshot.model.PseudoReference;
-import org.eclipse.mat.snapshot.model.ThreadToLocalReference;
-
-/**
- * @noextend
- */
-public class InstanceImpl extends AbstractObjectImpl implements IInstance {
- private static final long serialVersionUID = 1L;
-
- private volatile List<Field> fields;
- private volatile Map<String, Field> name2field;
-
- public InstanceImpl(int objectId, long address, ClassImpl clazz, List<Field> fields) {
- super(objectId, address, clazz);
- this.fields = fields;
- }
-
- @Override public long getObjectAddress() {
- try {
- long address = super.getObjectAddress();
-
- if (address == Long.MIN_VALUE) {
- address = source.mapIdToAddress(getObjectId());
- setObjectAddress(address);
- }
-
- return address;
- } catch (SnapshotException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override public int getObjectId() {
- try {
- int objectId = super.getObjectId();
-
- if (objectId < 0) {
- objectId = source.mapAddressToId(getObjectAddress());
- setObjectId(objectId);
- }
-
- return objectId;
- } catch (SnapshotException e) {
- throw new RuntimeException(e);
- }
- }
-
- public List<Field> getFields() {
- if (fields == null) readFully();
-
- return fields;
- }
-
- public Field getField(String name) {
- return internalGetField(name);
- }
-
- protected void setFields(List<Field> fields) {
- this.fields = fields;
- }
-
- protected synchronized void readFully() {
- // test again after synchronization
- if (fields != null) return;
-
- try {
- int objectId = getObjectId();
-
- InstanceImpl fullCopy = (InstanceImpl) source.getHeapObjectReader().read(objectId, source);
- this.setObjectAddress(fullCopy.getObjectAddress());
- this.fields = fullCopy.fields;
- } catch (IOException e) {
- throw new RuntimeException(e);
- } catch (SnapshotException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override public int getUsedHeapSize() {
- try {
- return getSnapshot().getHeapSize(getObjectId());
- } catch (SnapshotException e) {
- return classInstance.getHeapSizePerInstance();
- }
- }
-
- public ArrayLong getReferences() {
- List<Field> fields = getFields();
- ArrayLong list = new ArrayLong(fields.size() + 1);
-
- list.add(classInstance.getObjectAddress());
-
- HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> threadToLocalVars =
- source.getRootsPerThread();
- if (threadToLocalVars != null) {
- HashMapIntObject<XGCRootInfo[]> localVars = threadToLocalVars.get(getObjectId());
- if (localVars != null) {
- IteratorInt localsIds = localVars.keys();
- while (localsIds.hasNext()) {
- int localId = localsIds.next();
- GCRootInfo[] rootInfo = localVars.get(localId);
- list.add(rootInfo[0].getObjectAddress());
- }
- }
- }
-
- for (Field field : fields) {
- if (field.getValue() instanceof ObjectReference) {
- ObjectReference ref = (ObjectReference) field.getValue();
- list.add(ref.getObjectAddress());
- }
- }
-
- return list;
- }
-
- public List<NamedReference> getOutboundReferences() {
- List<NamedReference> list = new ArrayList<NamedReference>();
-
- list.add(new PseudoReference(source, classInstance.getObjectAddress(), "<class>"));//$NON-NLS-1$
-
- HashMapIntObject<HashMapIntObject<XGCRootInfo[]>> threadToLocalVars =
- source.getRootsPerThread();
- if (threadToLocalVars != null) {
- HashMapIntObject<XGCRootInfo[]> localVars = threadToLocalVars.get(getObjectId());
- if (localVars != null) {
- IteratorInt localsIds = localVars.keys();
- while (localsIds.hasNext()) {
- int localId = localsIds.next();
- GCRootInfo[] rootInfo = localVars.get(localId);
- ThreadToLocalReference ref =
- new ThreadToLocalReference(source, rootInfo[0].getObjectAddress(), "<"//$NON-NLS-1$
- + GCRootInfo.getTypeSetAsString(rootInfo) + ">", localId, rootInfo);//$NON-NLS-1$
- list.add(ref);
- }
- }
- }
-
- for (Field field : getFields()) {
- if (field.getValue() instanceof ObjectReference) {
- ObjectReference ref = (ObjectReference) field.getValue();
- list.add(new NamedReference(source, ref.getObjectAddress(), field.getName()));
- }
- }
-
- return list;
- }
-
- @Override protected Field internalGetField(String name) {
- if (name2field == null) {
- List<Field> fields = getFields();
- Map<String, Field> n2f = new HashMap<String, Field>(fields.size());
- for (Field f : fields) {
- n2f.put(f.getName(), f);
- }
-
- this.name2field = n2f;
- }
-
- return name2field.get(name);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/model/ObjectArrayImpl.java b/src/main/java/org/eclipse/mat/parser/model/ObjectArrayImpl.java
deleted file mode 100644
index 1b33607..0000000
--- a/src/main/java/org/eclipse/mat/parser/model/ObjectArrayImpl.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.model;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.ArrayLong;
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.snapshot.model.Field;
-import org.eclipse.mat.snapshot.model.IObject;
-import org.eclipse.mat.snapshot.model.IObjectArray;
-import org.eclipse.mat.snapshot.model.NamedReference;
-import org.eclipse.mat.snapshot.model.ObjectReference;
-import org.eclipse.mat.snapshot.model.PseudoReference;
-import org.eclipse.mat.util.MessageUtil;
-
-/**
- * @noextend
- */
-public class ObjectArrayImpl extends AbstractArrayImpl implements IObjectArray {
- private static final long serialVersionUID = 2L;
-
- public ObjectArrayImpl(int objectId, long address, ClassImpl classInstance, int length) {
- super(objectId, address, classInstance, length);
- }
-
- @Override public int getUsedHeapSize() {
- try {
- return getSnapshot().getHeapSize(getObjectId());
- } catch (SnapshotException e) {
- return doGetUsedHeapSize(classInstance, length);
- }
- }
-
- public static int doGetUsedHeapSize(ClassImpl clazz, int length) {
- return alignUpTo8(
- 2 * clazz.getHeapSizePerInstance() + 4 + length * clazz.getHeapSizePerInstance());
- }
-
- public long[] getReferenceArray() {
- try {
- return source.getHeapObjectReader().readObjectArrayContent(this, 0, getLength());
- } catch (SnapshotException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public long[] getReferenceArray(int offset, int length) {
- try {
- return source.getHeapObjectReader().readObjectArrayContent(this, offset, length);
- } catch (SnapshotException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public ArrayLong getReferences() {
- ArrayLong answer = new ArrayLong(getLength() + 1);
-
- answer.add(classInstance.getObjectAddress());
-
- long refs[] = getReferenceArray();
- for (int i = 0; i < refs.length; i++) {
- if (refs[i] != 0) {
- answer.add(refs[i]);
- }
- }
-
- return answer;
- }
-
- protected Field internalGetField(String name) {
- if (name.charAt(0) != '[' || name.charAt(name.length() - 1) != ']') return null;
-
- try {
- int index = Integer.parseInt(name.substring(1, name.length() - 1));
- if (index < 0 || index > length) {
- throw new IndexOutOfBoundsException(
- MessageUtil.format(Messages.ObjectArrayImpl_forArray, index, getTechnicalName()));
- }
-
- long[] references = source.getHeapObjectReader().readObjectArrayContent(this, index, 1);
- return new Field(name, IObject.Type.OBJECT, new ObjectReference(source, references[0]));
- } catch (SnapshotException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public List<NamedReference> getOutboundReferences() {
- List<NamedReference> answer = new ArrayList<NamedReference>(getLength() + 1);
-
- answer.add(
- new PseudoReference(source, classInstance.getObjectAddress(), "<class>"));//$NON-NLS-1$
-
- long refs[] = getReferenceArray();
- for (int i = 0; i < refs.length; i++) {
- if (refs[i] != 0) {
- StringBuilder builder = new StringBuilder();
- builder.append('[').append(i).append(']');
-
- answer.add(new NamedReference(source, refs[i], builder.toString()));
- }
- }
-
- return answer;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/model/PrimitiveArrayImpl.java b/src/main/java/org/eclipse/mat/parser/model/PrimitiveArrayImpl.java
deleted file mode 100644
index 82c3fcc..0000000
--- a/src/main/java/org/eclipse/mat/parser/model/PrimitiveArrayImpl.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.model;
-
-import java.io.IOException;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.ArrayLong;
-import org.eclipse.mat.snapshot.model.Field;
-import org.eclipse.mat.snapshot.model.IPrimitiveArray;
-import org.eclipse.mat.snapshot.model.NamedReference;
-import org.eclipse.mat.snapshot.model.PseudoReference;
-
-/**
- * @noextend
- */
-public class PrimitiveArrayImpl extends AbstractArrayImpl implements IPrimitiveArray {
- private static final long serialVersionUID = 2L;
-
- private int type;
-
- public PrimitiveArrayImpl(int objectId, long address, ClassImpl classInstance, int length,
- int type) {
- super(objectId, address, classInstance, length);
- this.type = type;
- }
-
- public int getType() {
- return type;
- }
-
- public Class<?> getComponentType() {
- return COMPONENT_TYPE[type];
- }
-
- public Object getValueAt(int index) {
- Object data = getValueArray(index, 1);
- return data != null ? Array.get(data, 0) : null;
- }
-
- public Object getValueArray() {
- try {
- return source.getHeapObjectReader().readPrimitiveArrayContent(this, 0, getLength());
- } catch (SnapshotException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public Object getValueArray(int offset, int length) {
- try {
- return source.getHeapObjectReader().readPrimitiveArrayContent(this, offset, length);
- } catch (SnapshotException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- protected Field internalGetField(String name) {
- return null;
- }
-
- @Override public ArrayLong getReferences() {
- ArrayLong references = new ArrayLong(1);
- references.add(classInstance.getObjectAddress());
- return references;
- }
-
- public List<NamedReference> getOutboundReferences() {
- List<NamedReference> references = new ArrayList<NamedReference>(1);
- references.add(
- new PseudoReference(source, classInstance.getObjectAddress(), "<class>"));//$NON-NLS-1$
- return references;
- }
-
- @Override protected StringBuffer appendFields(StringBuffer buf) {
- return super.appendFields(buf).append(";size=").append(getUsedHeapSize());//$NON-NLS-1$
- }
-
- @Override public int getUsedHeapSize() {
- try {
- return getSnapshot().getHeapSize(getObjectId());
- } catch (SnapshotException e) {
- return doGetUsedHeapSize(classInstance, length, type);
- }
- }
-
- public static int doGetUsedHeapSize(ClassImpl clazz, int length, int type) {
- return alignUpTo8(2 * clazz.getHeapSizePerInstance() + 4 + length * ELEMENT_SIZE[type]);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/model/XGCRootInfo.java b/src/main/java/org/eclipse/mat/parser/model/XGCRootInfo.java
deleted file mode 100644
index 9d5e03b..0000000
--- a/src/main/java/org/eclipse/mat/parser/model/XGCRootInfo.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.model;
-
-import org.eclipse.mat.snapshot.model.GCRootInfo;
-
-public final class XGCRootInfo extends GCRootInfo {
- private static final long serialVersionUID = 1L;
-
- public XGCRootInfo(long objectAddress, long contextAddress, int type) {
- super(objectAddress, contextAddress, type);
- }
-
- public void setObjectId(int objectId) {
- this.objectId = objectId;
- }
-
- public void setContextId(int objectId) {
- this.contextId = objectId;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/parser/model/XSnapshotInfo.java b/src/main/java/org/eclipse/mat/parser/model/XSnapshotInfo.java
deleted file mode 100644
index 26de0e8..0000000
--- a/src/main/java/org/eclipse/mat/parser/model/XSnapshotInfo.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.parser.model;
-
-import java.util.Date;
-import org.eclipse.mat.snapshot.SnapshotInfo;
-
-public final class XSnapshotInfo extends SnapshotInfo {
- private static final long serialVersionUID = 3L;
-
- public XSnapshotInfo() {
- super(null, null, null, 0, null, 0, 0, 0, 0, 0);
- }
-
- public void setPrefix(String prefix) {
- this.prefix = prefix;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public void setCreationDate(Date creationDate) {
- this.creationDate = new Date(creationDate.getTime());
- }
-
- public void setIdentifierSize(int identifierSize) {
- this.identifierSize = identifierSize;
- }
-
- public void setJvmInfo(String jvmInfo) {
- this.jvmInfo = jvmInfo;
- }
-
- public void setNumberOfClasses(int numberOfClasses) {
- this.numberOfClasses = numberOfClasses;
- }
-
- public void setNumberOfClassLoaders(int numberOfClassLoaders) {
- this.numberOfClassLoaders = numberOfClassLoaders;
- }
-
- public void setNumberOfGCRoots(int numberOfGCRoots) {
- this.numberOfGCRoots = numberOfGCRoots;
- }
-
- public void setNumberOfObjects(int numberOfObjects) {
- this.numberOfObjects = numberOfObjects;
- }
-
- public void setUsedHeapSize(long usedHeapSize) {
- this.usedHeapSize = usedHeapSize;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/DominatorsSummary.java b/src/main/java/org/eclipse/mat/snapshot/DominatorsSummary.java
deleted file mode 100644
index 4ea1a57..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/DominatorsSummary.java
+++ /dev/null
@@ -1,519 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.mat.collect.SetInt;
-import org.eclipse.mat.snapshot.model.IObject;
-
-/**
- * This class holds the data of a dominators summary (see
- * ISnapshot.getDominatorsOf()). For a given list of objects the summary
- * contains the dominators of the single objects grouped by class or by class
- * loader.#
- *
- * @noinstantiate
- */
-public final class DominatorsSummary {
-
- private ClassDominatorRecord[] classDominatorRecords;
- private ClassloaderDominatorRecord[] classloaderDominatorRecords;
-
- private ISnapshot snapshot;
-
- private Object data;
-
- public DominatorsSummary(ClassDominatorRecord[] classDominatorRecords, ISnapshot snapshot) {
- this.classDominatorRecords = classDominatorRecords;
- this.snapshot = snapshot;
-
- for (ClassDominatorRecord record : classDominatorRecords)
- record.summary = this;
- }
-
- /**
- * Returns data object attached to the summary. Needed for UI elements to
- * store context.
- */
- public Object getData() {
- return data;
- }
-
- /**
- * Attaches arbitrary data object to the summary. Needed for UI elements to
- * store context.
- */
- public void setData(Object data) {
- this.data = data;
- }
-
- /**
- * Get the dominators summary grouped by classes
- *
- * @return ClassDominatorRecord[] the array of ClassDominatorRecords
- */
- public ClassDominatorRecord[] getClassDominatorRecords() {
- return classDominatorRecords;
- }
-
- /**
- * Get the dominators summary grouped by class loaders
- *
- * @return ClassloaderDominatorRecord[] the array of
- * ClassloaderDominatorRecords
- */
- public ClassloaderDominatorRecord[] getClassloaderDominatorRecords() {
- return getClassloaderDominatorRecords(ClassloaderDominatorRecord.class);
- }
-
- @SuppressWarnings("unchecked")
- public <C extends ClassloaderDominatorRecord> C[] getClassloaderDominatorRecords(
- Class<C> factoryClass) {
- synchronized (this) {
- if (classloaderDominatorRecords == null) {
- classloaderDominatorRecords = load((Class<ClassloaderDominatorRecord>) factoryClass);
- }
- }
- return (C[]) classloaderDominatorRecords;
- }
-
- private ClassloaderDominatorRecord[] load(Class<ClassloaderDominatorRecord> factoryClass) {
- try {
-
- Map<Integer, ClassloaderDominatorRecord> map =
- new HashMap<Integer, ClassloaderDominatorRecord>();
- for (ClassDominatorRecord record : classDominatorRecords) {
- ClassloaderDominatorRecord clr = map.get(record.getClassloaderId());
- if (clr == null) {
- map.put(record.getClassloaderId(), clr = factoryClass.newInstance());
-
- clr.setId(record.getClassloaderId());
-
- if (clr.getId() == -1) {
- clr.name = "<ROOT>"; //$NON-NLS-1$
- } else {
- IObject object = snapshot.getObject(clr.id);
- clr.name = object.getClassSpecificName();
- if (clr.name == null) clr.name = object.getTechnicalName();
- }
- }
-
- clr.dominated += record.getDominatedCount();
- clr.dominator += record.getDominatorCount();
- clr.dominatedNetSize += record.getDominatedNetSize();
- clr.dominatorNetSize += record.getDominatorNetSize();
-
- clr.records.add(record);
- }
-
- return map.values().toArray(new ClassloaderDominatorRecord[map.size()]);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * A record containing information for objects loaded by one class loader
- * dominating a set of other objects
- */
- public static class ClassloaderDominatorRecord {
- protected List<ClassDominatorRecord> records = new ArrayList<ClassDominatorRecord>();
- protected String name;
- protected int id;
-
- long dominatedNetSize;
- long dominatorNetSize;
- long dominatorRetainedSize;
- long dominatedRetainedSize;
- int dominated;
- int dominator;
-
- public String getName() {
- return name;
- }
-
- /**
- * Get the total net size of the dominated objects
- */
- public long getDominatedNetSize() {
- return dominatedNetSize;
- }
-
- /**
- * Get the number of dominated objects
- */
- public int getDominatedCount() {
- return dominated;
- }
-
- /**
- * Get the total net size of the dominators
- */
- public int getDominatorCount() {
- return dominator;
- }
-
- /**
- * Get the total net size of the dominators
- */
- public long getDominatorNetSize() {
- return dominatorNetSize;
- }
-
- public List<ClassDominatorRecord> getRecords() {
- return records;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public long getDominatedRetainedSize() {
- return dominatedRetainedSize;
- }
-
- public void setDominatedRetainedSize(long dominatedRetainedSize) {
- this.dominatedRetainedSize = dominatedRetainedSize;
- }
-
- public long getDominatorRetainedSize() {
- return dominatorRetainedSize;
- }
-
- public void setDominatorRetainedSize(long dominatorRetainedSize) {
- this.dominatorRetainedSize = dominatorRetainedSize;
- }
- }
-
- /**
- * A record containing information for objects of one class dominating a set
- * of other objects
- */
- public static class ClassDominatorRecord {
- DominatorsSummary summary;
-
- String className;
- int classloaderId;
- int classId;
-
- long dominatedNetSize;
- long dominatorNetSize;
-
- long dominatedRetainedSize;
- long dominatorRetainedSize;
-
- SetInt dominated = new SetInt(500);
- SetInt dominator = new SetInt(500);
-
- /**
- * Get the name of the class for this record
- */
- public String getClassName() {
- return className;
- }
-
- /**
- * Set the name of the class of this record
- */
- public void setClassName(String className) {
- this.className = className;
- }
-
- public int getClassId() {
- return classId;
- }
-
- public void setClassId(int classId) {
- this.classId = classId;
- }
-
- /**
- * Get the total net size of the dominated objects
- */
- public long getDominatedNetSize() {
- return dominatedNetSize;
- }
-
- /**
- * Get the total net size of the dominators
- */
- public long getDominatorNetSize() {
- return dominatorNetSize;
- }
-
- /**
- * Get the total retained heap size of the dominated objects
- */
- public long getDominatedRetainedSize() {
- return dominatedRetainedSize;
- }
-
- /**
- * Set the retained heap size of the dominated objects
- */
- public void setDominatedRetainedSize(long dominatedRetainedSize) {
- this.dominatedRetainedSize = dominatedRetainedSize;
- }
-
- /**
- * Get the retained heap size of the dominators
- */
- public long getDominatorRetainedSize() {
- return dominatorRetainedSize;
- }
-
- /**
- * Set the retained heap size of the dominators
- */
- public void setDominatorRetainedSize(long dominatorRetainedSize) {
- this.dominatorRetainedSize = dominatorRetainedSize;
- }
-
- /**
- * Get the number of dominated objects
- */
- public int getDominatedCount() {
- return dominated.size();
- }
-
- /**
- * Get the number of dominators
- *
- * @return the number of dominators
- */
- public int getDominatorCount() {
- return dominator.size();
- }
-
- /**
- * get the id of the classloader of the dominators' class
- */
- public int getClassloaderId() {
- return classloaderId;
- }
-
- /**
- * set the id of the classloader of the dominators
- */
- public void setClassloaderId(int classloaderId) {
- this.classloaderId = classloaderId;
- }
-
- /**
- * Add a dominated object to the record
- */
- public boolean addDominated(int objectId) {
- return this.dominated.add(objectId);
- }
-
- /**
- * Add a dominator to the record
- */
- public boolean addDominator(int objectId) {
- return this.dominator.add(objectId);
- }
-
- /**
- * Increase the dominated net heap size
- */
- public void addDominatedNetSize(long size) {
- dominatedNetSize += size;
- }
-
- /**
- * Increase the dominators total size
- */
- public void addDominatorNetSize(long size) {
- dominatorNetSize += size;
- }
-
- /**
- * Get the dominated objects
- *
- * @return int[] - an array with the ids of all dominated objects
- */
- public int[] getDominated() {
- return dominated.toArray();
- }
-
- /**
- * Get the dominator objects
- *
- * @return int[] - an array with the ids of the dominators
- */
- public int[] getDominators() {
- return dominator.toArray();
- }
-
- /**
- * Get the DominatorsSummary to which this record belongs.
- *
- * @return this records's DominatorsSummery
- */
- public DominatorsSummary getSummary() {
- return summary;
- }
- }
-
- /**
- * A comparator by name
- */
- public static final Comparator<Object> COMPARE_BY_NAME = new Comparator<Object>() {
- public int compare(Object o1, Object o2) {
- if (o1 instanceof ClassDominatorRecord) {
- return ((ClassDominatorRecord) o1).getClassName()
- .compareTo(((ClassDominatorRecord) o2).getClassName());
- } else {
- return ((ClassloaderDominatorRecord) o1).getName()
- .compareTo(((ClassloaderDominatorRecord) o2).getName());
- }
- }
- };
-
- /**
- * A comparator by number of dominators
- */
- public static final Comparator<Object> COMPARE_BY_DOMINATORS = new Comparator<Object>() {
- public int compare(Object o1, Object o2) {
- int c1 = 0;
- int c2 = 0;
-
- if (o1 instanceof ClassDominatorRecord) {
- c1 = ((ClassDominatorRecord) o1).getDominatorCount();
- c2 = ((ClassDominatorRecord) o2).getDominatorCount();
- } else {
- c1 = ((ClassloaderDominatorRecord) o1).getDominatorCount();
- c2 = ((ClassloaderDominatorRecord) o2).getDominatorCount();
- }
-
- return c1 > c2 ? 1 : c1 == c2 ? 0 : -1;
- }
- };
-
- /**
- * A comparator by number of dominated objects
- */
- public static final Comparator<Object> COMPARE_BY_DOMINATED = new Comparator<Object>() {
- public int compare(Object o1, Object o2) {
- int c1 = 0;
- int c2 = 0;
-
- if (o1 instanceof ClassDominatorRecord) {
- c1 = ((ClassDominatorRecord) o1).getDominatedCount();
- c2 = ((ClassDominatorRecord) o2).getDominatedCount();
- } else {
- c1 = ((ClassloaderDominatorRecord) o1).getDominatedCount();
- c2 = ((ClassloaderDominatorRecord) o2).getDominatedCount();
- }
-
- return c1 > c2 ? 1 : c1 == c2 ? 0 : -1;
- }
- };
-
- /**
- * A comparator by dominated heap size
- */
- public static final Comparator<Object> COMPARE_BY_DOMINATED_HEAP_SIZE = new Comparator<Object>() {
- public int compare(Object o1, Object o2) {
- long c1 = 0;
- long c2 = 0;
-
- if (o1 instanceof ClassDominatorRecord) {
- c1 = ((ClassDominatorRecord) o1).getDominatedNetSize();
- c2 = ((ClassDominatorRecord) o2).getDominatedNetSize();
- } else {
- c1 = ((ClassloaderDominatorRecord) o1).getDominatedNetSize();
- c2 = ((ClassloaderDominatorRecord) o2).getDominatedNetSize();
- }
-
- return c1 > c2 ? 1 : c1 == c2 ? 0 : -1;
- }
- };
-
- /**
- * A comparator by dominators heap size
- */
- public static final Comparator<Object> COMPARE_BY_DOMINATOR_HEAP_SIZE = new Comparator<Object>() {
- public int compare(Object o1, Object o2) {
- long c1 = 0;
- long c2 = 0;
- if (o1 instanceof ClassDominatorRecord) {
- c1 = ((ClassDominatorRecord) o1).getDominatorNetSize();
- c2 = ((ClassDominatorRecord) o2).getDominatorNetSize();
- } else {
- c1 = ((ClassloaderDominatorRecord) o1).getDominatorNetSize();
- c2 = ((ClassloaderDominatorRecord) o2).getDominatorNetSize();
- }
- return c1 > c2 ? 1 : c1 == c2 ? 0 : -1;
- }
- };
-
- /**
- * A comparator by dominated objects' retained size
- */
- public static final Comparator<Object> COMPARE_BY_DOMINATED_RETAINED_HEAP_SIZE =
- new Comparator<Object>() {
- public int compare(Object o1, Object o2) {
- long c1 = 0;
- long c2 = 0;
-
- if (o1 instanceof ClassDominatorRecord) {
- c1 = ((ClassDominatorRecord) o1).getDominatedRetainedSize();
- c2 = ((ClassDominatorRecord) o2).getDominatedRetainedSize();
- } else {
- c1 = ((ClassloaderDominatorRecord) o1).getDominatedRetainedSize();
- c2 = ((ClassloaderDominatorRecord) o2).getDominatedRetainedSize();
- }
- return c1 > c2 ? 1 : c1 == c2 ? 0 : -1;
- }
- };
-
- /**
- * A comparator by dominators' retained size
- */
- public static final Comparator<Object> COMPARE_BY_DOMINATOR_RETAINED_HEAP_SIZE =
- new Comparator<Object>() {
- public int compare(Object o1, Object o2) {
- long c1 = 0;
- long c2 = 0;
-
- if (o1 instanceof ClassDominatorRecord) {
- c1 = ((ClassDominatorRecord) o1).getDominatorRetainedSize();
- c2 = ((ClassDominatorRecord) o2).getDominatorRetainedSize();
- } else {
- c1 = ((ClassloaderDominatorRecord) o1).getDominatorRetainedSize();
- c2 = ((ClassloaderDominatorRecord) o2).getDominatorRetainedSize();
- }
- return c1 > c2 ? 1 : c1 == c2 ? 0 : -1;
- }
- };
-
- /**
- * Reverse the sort order.
- */
- public static Comparator<Object> reverseComparator(final Comparator<Object> comparator) {
- return new Comparator<Object>() {
- public int compare(Object o1, Object o2) {
- return comparator.compare(o2, o1);
- }
- };
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/ExcludedReferencesDescriptor.java b/src/main/java/org/eclipse/mat/snapshot/ExcludedReferencesDescriptor.java
deleted file mode 100644
index db340c6..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/ExcludedReferencesDescriptor.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-public final class ExcludedReferencesDescriptor {
- private int[] objectIds;
- private Set<String> fields;
-
- public ExcludedReferencesDescriptor(int[] objectIds, Set<String> fields) {
- this.fields = fields;
- this.objectIds = objectIds;
- Arrays.sort(this.objectIds);
- }
-
- public ExcludedReferencesDescriptor(int[] objectIds, String... fields) {
- this(objectIds, new HashSet<String>(Arrays.asList(fields)));
- }
-
- public Set<String> getFields() {
- return fields;
- }
-
- public boolean contains(int objectId) {
- return Arrays.binarySearch(objectIds, objectId) >= 0;
- }
-
- public int[] getObjectIds() {
- return objectIds;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/IMultiplePathsFromGCRootsComputer.java b/src/main/java/org/eclipse/mat/snapshot/IMultiplePathsFromGCRootsComputer.java
deleted file mode 100644
index 8c495f2..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/IMultiplePathsFromGCRootsComputer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot;
-
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.util.IProgressListener;
-
-/**
- * Objects of this type can be used to work with paths to many objects
- *
- * @noimplement
- */
-public interface IMultiplePathsFromGCRootsComputer {
- /**
- * Calculates (if not yet calculated) and returns all the paths. The paths
- * are grouped by the GC root object, i.e. all paths starting from one and
- * the same GC root will be packed in one MultiplePathsFromGCRootsRecord.
- * This record can be used to get the objects at the next level in the path,
- * etc...
- *
- * @param progressListener - used to track the progress of the computation
- * @return MultiplePathsFromGCRootsRecord[] one record for each group of
- * paths starting from the same GC root
- * @throws SnapshotException
- */
- public MultiplePathsFromGCRootsRecord[] getPathsByGCRoot(IProgressListener progressListener)
- throws SnapshotException;
-
- /**
- * Calculates (if not yet calculated) and returns all the paths. Each
- * element in the Object[] is an int[] representing the path. The first
- * element in the int[] is the specified object, and the last is the GC root
- * object
- *
- * @param progressListener - used to track the progress of the computation
- * @return Object[] - each element in the array is an int[] representing a
- * path
- * @throws SnapshotException
- */
- public Object[] getAllPaths(IProgressListener progressListener) throws SnapshotException;
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/IPathsFromGCRootsComputer.java b/src/main/java/org/eclipse/mat/snapshot/IPathsFromGCRootsComputer.java
deleted file mode 100644
index 7882573..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/IPathsFromGCRootsComputer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot;
-
-import java.util.Collection;
-import org.eclipse.mat.SnapshotException;
-
-/**
- * Interface describing an interactive computer for paths from GC roots to an
- * object. You will get such a computer from the {@link ISnapshot} API.
- * <p>
- * Finding paths from GC roots to an object is handy if you want to learn which
- * objects are responsible for the given object to remain in memory. Since the
- * snapshot implementation artificially creates references from the object to
- * its class and from the class to its class loader you can even see why a class
- * or class loader remains in memory, i.e. which other objects hold references
- * to objects of the class or class loader of interest.
- *
- * @noimplement
- */
-public interface IPathsFromGCRootsComputer {
- /**
- * Get next shortest path. The computer holds the state of the computation
- * and allows to continuously ask for the next path. If null is returned no
- * path is available anymore.
- * <p>
- * This method allows you either to ask for all paths (which could take
- * quite some time and memory but shows you the complete picture) or one by
- * one (the shortest paths are returned first; more useful in an UI as a
- * user might find a problem faster among just a few shorter paths).
- *
- * @return int array holding the object ids of the objects forming the path
- * from the first element at index 0 (object for which the
- * computation was started) to the last element in the int array
- * (object identified as GC root)
- * @throws SnapshotException
- */
- public int[] getNextShortestPath() throws SnapshotException;
-
- /**
- * Helper method constructing a tree like data structure from the given
- * paths. Either all so far collected paths could be dropped in here or just
- * the last ones if you want to limit the view.
- *
- * @param paths paths from GC roots previously returned by
- * {@link #getNextShortestPath}
- * @return tree like data structure holding the paths from GC roots
- */
- public PathsFromGCRootsTree getTree(Collection<int[]> paths);
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/ISnapshot.java b/src/main/java/org/eclipse/mat/snapshot/ISnapshot.java
deleted file mode 100644
index f7d5f9c..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/ISnapshot.java
+++ /dev/null
@@ -1,593 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.snapshot.model.GCRootInfo;
-import org.eclipse.mat.snapshot.model.IClass;
-import org.eclipse.mat.snapshot.model.IObject;
-import org.eclipse.mat.snapshot.model.IThreadStack;
-import org.eclipse.mat.util.IProgressListener;
-
-/**
- * Interface for snapshots. It is the central API for handling HPROF snapshots.
- * <p>
- * A snapshot basically has an {@link SnapshotInfo} object describing it and
- * various methods operating on it. Be aware that such a snapshot potentially
- * holds quite a lot of memory, so try to keep not too many open at the same
- * time.
- * <p>
- * The basic "handle" you will encounter in the API is an <code>int</code>. It
- * is the id of an object and is always of the size of four bytes (no matter if
- * 32 or 64 bit). Operations are either performed on <code>int</code> or
- * <code>int[]</code> (addresses are stored in longs, but they should be used
- * only for display purposes). In order to simplify working with them and for
- * performance reasons compared to <code>Collection<Integer></code> some
- * helper classes are provided and you are strongly advised to use them:
- * BitField (for huge fixed bit fields), ArrayIntBig and ArrayLongBig (for huge
- * growing arrays) and ArrayIntCompressed and ArrayLongCompressed (for
- * fixed-size compressed arrays).
- *
- * @noimplement
- */
-public interface ISnapshot {
-
- /**
- * Get info object describing the snapshot.
- * <p>
- * Performance: Fast - in memory.
- *
- * @return info object describing the snapshot
- */
- public SnapshotInfo getSnapshotInfo();
-
- /**
- * Get all GC roots.
- * <p>
- * A GC root is an object which doesn't need to be referenced to remain in
- * the heap, e.g. all objects created in the thread stack frame.
- * <p>
- * Performance: Fast - in memory.
- *
- * @return int[] containing the objectIds of all GC roots
- * @throws SnapshotException
- */
- public int[] getGCRoots() throws SnapshotException;
-
- /**
- * Get all classes.
- * <p>
- * The returned class is a snapshot representation of a Java class. It
- * offers means to get to its name, class loader, fields, inheritance
- * relationships and most importantly to all of its objects found in the
- * heap.
- * <p>
- * Performance: Fast - in memory.
- *
- * @return collection of all classes
- * @throws SnapshotException
- */
- public Collection<IClass> getClasses() throws SnapshotException;
-
- /**
- * Get all classes by name.
- * <p>
- * This method returns you for one full class name all classes with this
- * name. Usually you will get only one class back, but in the case of
- * multiple class loaders which have loaded a class with the same name twice
- * (or even the same class) you will get multiple snapshot class
- * representations back as only the combination of class and class loader is
- * unique, not the name alone.
- * <p>
- * Performance: Fast - in memory.
- *
- * @param name name for the class
- * @param includeSubClasses flag indicating whether or not to include also classes derived
- * from matching classes (the name isn't taken into account for
- * sub classes anymore)
- * @return collection of matching classes
- * @throws SnapshotException
- */
- public Collection<IClass> getClassesByName(String name, boolean includeSubClasses)
- throws SnapshotException;
-
- /**
- * Get all classes by name pattern.
- * <p>
- * This method returns you all classes with a name matching the regular
- * expression pattern.
- * <p>
- * Performance: Fast - in memory, but needs iteration over all classes.
- *
- * @param namePattern name pattern for the class (regular expression)
- * @param includeSubClasses flag indicating whether or not to include also classes derived
- * from matching classes (the name isn't taken into account for
- * sub classes anymore)
- * @return collection of matching classes
- * @throws SnapshotException
- */
- public Collection<IClass> getClassesByName(Pattern namePattern, boolean includeSubClasses)
- throws SnapshotException;
-
- /**
- * Get histogram for the whole snapshot.
- * <p>
- * This histogram lists all classes and class loaders and how many objects
- * of the classes exist in the snapshot along with the memory consumption.
- * <p>
- * Performance: Fast - in memory.
- *
- * @param progressListener
- * progress listener informing about the current state of
- * execution
- * @return histogram
- * @throws SnapshotException
- */
- // public Histogram getHistogram(IProgressListener progressListener) throws SnapshotException;
-
- /**
- * Get histogram for some specific objects - usually the result of other
- * calls to the snapshot.
- * <p>
- * This histogram lists all classes and class loaders and how many objects
- * of the classes exist among the given objects along with the memory
- * consumption.
- * <p>
- * Performance: Fast to medium - on index (object id -> class id); depending
- * on the number of objects.
- *
- * @param objectIds
- * object ids for which the histogram should be computed
- * @param progressListener
- * progress listener informing about the current state of
- * execution
- * @return histogram
- * @throws SnapshotException
- */
- // public Histogram getHistogram(int[] objectIds, IProgressListener progressListener) throws SnapshotException;
-
- /**
- * Get all objects referencing the given object.
- * <p>
- * Performance: Relatively fast - single index operation.
- *
- * @param objectId object which is referenced
- * @return objects referencing the given object
- * @throws SnapshotException
- */
- public int[] getInboundRefererIds(int objectId) throws SnapshotException;
-
- /**
- * Get all objects referenced by the given object.
- * <p>
- * Performance: Relatively fast - single index operation.
- *
- * @param objectId object which is referencing
- * @return objects referenced by the given object
- * @throws SnapshotException
- */
- public int[] getOutboundReferentIds(int objectId) throws SnapshotException;
-
- /**
- * Get all objects referencing the given objects.
- * <p>
- * Hint: This method is handy if you want to learn which classes reference a
- * class. Therefore you would call this method with all objects of your
- * class of interest and get a histogram out of the result.
- * <p>
- * Performance: Fast to slow - on index; depending on the number of objects
- * and the references.
- *
- * @param objectIds objects which are referenced
- * @param progressListener progress listener informing about the current state of
- * execution
- * @return objects referencing the given objects
- * @throws SnapshotException
- */
- public int[] getInboundRefererIds(int[] objectIds, IProgressListener progressListener)
- throws SnapshotException;
-
- /**
- * Get all objects referenced by the given objects.
- * <p>
- * Hint: This method is handy if you want to learn which classes are
- * referenced by a class. Therefore you would call this method with all
- * objects of your class of interest and get a histogram out of the result.
- * <p>
- * Performance: Fast to slow - on index; depending on the number of objects
- * and the references.
- *
- * @param objectIds objects which are referencing
- * @param progressListener progress listener informing about the current state of
- * execution
- * @return objects referenced by the given objects
- * @throws SnapshotException
- */
- public int[] getOutboundReferentIds(int[] objectIds, IProgressListener progressListener)
- throws SnapshotException;
-
- /**
- * Get interactive computer for paths from GC roots to the given object.
- * <p>
- * Hint: This method is handy if you want to learn which objects are
- * responsible for the given object to remain in memory. Since the snapshot
- * implementation artificially creates references from the object to its
- * class and from the class to its class loader you can even see why a class
- * or class loaders remains in memory, i.e. which other objects hold
- * references to objects of the class or class loader of interest.
- * <p>
- * Performance: Fast to slow - on index; depending on the number and length
- * of GC root paths.
- *
- * @param objectId object for which the GC root paths should be determined
- * @param excludeMap a map specifying paths through which objects have to be
- * avoided and not reported. Each entry in the map has the IClass
- * as a key, and a Set<String> set, specifying which fields
- * exactly from this key class have to be avoided. If for a key
- * IClass the value (Set<String>) null is specified, then paths
- * through any of the fields will be avoided
- * @return interactive computer for paths from GC roots to the given object
- * @throws SnapshotException
- */
- public IPathsFromGCRootsComputer getPathsFromGCRoots(int objectId,
- Map<IClass, Set<String>> excludeMap) throws SnapshotException;
-
- /**
- * Returns an IMultiplePathsFromGCRootsComputer object, which can be used to
- * calculate the shortest path from the GC roots to each of objects in the
- * specified object set.
- *
- * @param objectIds the IDs of the objects for which a shortest path has to be
- * calculated
- * @param excludeMap a map specifying paths through which objects have to be
- * avoided and not reported. Each entry in the map has the IClass
- * as a key, and a Set<String> set, specifying which fields
- * exactly from this key class have to be avoided. If for a key
- * IClass the value (Set<String>) null is specified, then paths
- * through any of the fields will be avoided
- * @return IMultiplePathsFromGCRootsComputer The object which can be used to
- * carry out the actual computation and
- * @throws SnapshotException
- */
- public IMultiplePathsFromGCRootsComputer getMultiplePathsFromGCRoots(int[] objectIds,
- Map<IClass, Set<String>> excludeMap) throws SnapshotException;
-
- /**
- * Get retained set of objects for the given objects (including the given
- * objects).
- * <p>
- * The retained set includes the given objects and all objects which are
- * lifetime-dependent on them, i.e. which would be garbage collected if the
- * references to the given objects would be lost and the objects garbage
- * collected.
- * <p>
- * Performance: Usually extremely slow - on index; depending on the number
- * of objects and the references (deep).
- *
- * @param objectIds objects on which the retained set should be determined
- * @param progressListener progress listener informing about the current state of
- * execution
- * @return retained set of objects for the given objects
- * @throws SnapshotException
- */
- public int[] getRetainedSet(int[] objectIds, IProgressListener progressListener)
- throws SnapshotException;
-
- /**
- * Get retained set of objects for the given fields at the given objects
- * (excluding the given objects).
- * <p>
- * The retained set includes the objects referenced by the fields on the
- * given objects and all objects which are lifetime-dependent on them, i.e.
- * which would be garbage collected if the references at the given fields at
- * the given objects would be nulled.
- * <p>
- * Performance: Usually extremely slow - on index; depending on the number
- * of objects and the references (deep).
- *
- * @param objectIds objects on which the retained set should be determined
- * @param progressMonitor progress listener informing about the current state of
- * execution
- * @return retained set of objects for the given objects
- * @throws SnapshotException
- */
- public int[] getRetainedSet(int[] objectIds, String[] fieldNames,
- IProgressListener progressMonitor) throws SnapshotException;
-
- public int[] getRetainedSet(int[] objectIds, ExcludedReferencesDescriptor[] excludedReferences,
- IProgressListener progressMonitor) throws SnapshotException;
-
- /**
- * Calculate the minimum retained set of objects for the given objects
- * (including the given objects).
- * <p>
- * The minimum retained set includes the given objects and the union of the
- * retained sets for each of the given objects (see getRetainedSet() for an
- * explanation of a retained set). The union of the retained sets of the
- * single objects is potentially smaller than the retained set of all of
- * them, because some objects which are shared between two of the given
- * objects may not appear in the retained set of any of the single objects,
- * but will appear in the retained set if we take them as a whole. Because
- * of it's faster performance the method is suitable to "mine" for a
- * potentially big retained set (e.g. execute this method for all class
- * loaders and see for potentially big ones). One can use the
- * getRetainedSet() method afterwards to get the correct retained set.
- * <p>
- * Performance: Usually fast - for smaller sets this method is much faster
- * than getRetainedSet
- *
- * @param objectIds objects on which the minimum retained set should be determined
- * @param progressListener progress listener informing about the current state of
- * execution
- * @return the minimum retained set of objects for the given objects
- * @throws SnapshotException
- */
- public int[] getMinRetainedSet(int[] objectIds, IProgressListener progressListener)
- throws SnapshotException;
-
- /**
- * Calculate the minimum retained size for the given objects. Works much
- * faster than getting the min. retained set by getMinRetainedSet() and
- * calculating the size of the min. retained set.
- *
- * @param objectIds objects on which the minimum retained set should be determined
- * @param listener progress listener informing about the current state of
- * execution
- * @return the minimum retained set of objects for the given objects
- * @throws SnapshotException
- */
- public long getMinRetainedSize(int[] objectIds, IProgressListener listener)
- throws SnapshotException;
-
- /**
- * Get objects the given object directly dominates, i.e. the objects which
- * are life-time dependent on the given object (not recursively, so just the
- * directly dependent objects), i.e. the objects which would get collected
- * as garbage if the given object would be gone from the heap.
- *
- * @param objectId object for which the directly dominated objects should be
- * returned
- * @return objects the given object directly dominates
- * @throws SnapshotException
- */
- public int[] getImmediateDominatedIds(int objectId) throws SnapshotException;
-
- /**
- * Get object which directly dominates the given object, i.e. the object
- * which controls the life-time of the given object (not recursively, so
- * just the directly controlling object), i.e. the object which would cause
- * the given object to be collected as garbage if it would be gone from the
- * heap.
- *
- * @param objectId object for which the directly dominated objects should be
- * returned
- * @return Object id of the dominator. -1 if the object is dominated by the
- * root of the dominator tree.
- * @throws SnapshotException
- */
- public int getImmediateDominatorId(int objectId) throws SnapshotException;
-
- /**
- * Get a summary of the dominators for all the given objects. The summary
- * can be viewed on grouped by classes or class loaders
- * <p>
- * If an exclude pattern is provided, instead of returning the immediate
- * dominator right away, its class name will be checked against the exclude
- * pattern. If it matches the pattern, the dominator of this dominator will
- * be taken and checked, and so on ... until a dominator not matching the
- * pattern is found or the dominator tree root is reached.
- *
- * @param objectIds the objects for which we want the dominator summary (e.g. all
- * objects of a given class)
- * @param excludePattern An exclude pattern. Domminators whose class name matches the
- * pattern will be omitted and their dominator will be taken
- * @param progressListener progress listener informing about the current state of
- * execution
- * @return DominatorsSummary the returned DominatorSummary contains the
- * summary of the dominators grouped by classes or class loaders
- * @throws SnapshotException
- */
- public DominatorsSummary getDominatorsOf(int[] objectIds, Pattern excludePattern,
- IProgressListener progressListener) throws SnapshotException;
-
- /**
- * Get the top-ancestors in the dominator tree from the supplied objectIds.
- * The result will be a list of objects (int[]), such that no object from
- * the return list is parent of another object in the returned list. I.e.
- * from a list of objects this method will return only the ones which are
- * independent on one another. It is then correct to sum the retained sizes
- * of the returned objects.
- *
- * @param objectIds the objects for which the top-ancestors in the Dominator tree
- * have to be found
- * @param listener progress listener informing about the current state of
- * execution
- * @return int[] the objects which not in a parent/child relation in the
- * dominator tree
- * @throws SnapshotException
- */
- public int[] getTopAncestorsInDominatorTree(int[] objectIds, IProgressListener listener)
- throws SnapshotException;
-
- /**
- * Get object abstracting the real Java Object from the heap dump identified
- * by the given id.
- * <p>
- * Performance: Relatively fast - single index operation.
- *
- * @param objectId id of object you want a convenient object abstraction for
- * @return object abstracting the real Java Object from the heap dump
- * identified by the given id
- * @throws SnapshotException
- */
- public IObject getObject(int objectId) throws SnapshotException;
-
- /**
- * Get the GC root info for an object. If the provided object is no GC root
- * null will be returned otherwise a GCRootInfo[]. An object can be a GC
- * root for more than one reason and the returned array will contain one
- * instance of GCRootInfo for each of the reasons (e.g. one GCRootInfo for
- * every thread where an object is a java local variable)
- * <p>
- * Performance: Fast - in memory.
- *
- * @param objectId id of object you want the GC root info for
- * @return null if this object is no GC root or GCRootInfo[] if it is
- * @throws SnapshotException
- */
- public GCRootInfo[] getGCRootInfo(int objectId) throws SnapshotException;
-
- /**
- * Get object abstracting the real Java Class this object was an instance of
- * in the heap dump identified by the given id.
- * <p>
- * Performance: Relatively fast - single index operation.
- *
- * @param objectId id of object you want the convenient class abstraction for
- * @return object abstracting the real Java Class this object was an
- * instance of in the heap dump identified by the given id
- * @throws SnapshotException
- */
- public IClass getClassOf(int objectId) throws SnapshotException;
-
- /**
- * Get heap size for the given object.
- * <p>
- * Performance: Usually fast - in memory for non-array objects and single
- * index operation for array objects.
- *
- * @param objectId id of object for which you want the heap size for
- * @return heap size for the given object
- * @throws SnapshotException
- */
- public int getHeapSize(int objectId) throws SnapshotException;
-
- /**
- * Get the total shallow heap size for a set of objects.
- * <p>
- * Performance: Relatively fast - using this method to calculate the total
- * size of a set of objects is much faster than iterating over the ids and
- * calling getHeapSize for each single object
- *
- * @param objectIds ids of the objects for which you want the heap size for
- * @return total heap size for the given object set
- * @throws SnapshotException
- */
- public long getHeapSize(int[] objectIds) throws SnapshotException;
-
- /**
- * Get retained heap size for the given object.
- * <p>
- * The retained heap size is the memory which would be freed if all
- * references to the given object would be released. It is extracted from
- * the dominator tree and isn't available if the dominator tree isn't
- * available itself.
- * <p>
- * Performance: Relatively fast - single index operation.
- *
- * @param objectId id of object for which you want the retained heap size for
- * @return retained heap size for the given object or 0 if no dominator tree
- * was calculated
- * @throws SnapshotException
- */
- public long getRetainedHeapSize(int objectId) throws SnapshotException;
-
- /**
- * Returns true if the object by this id is a class.
- * <p>
- * Performance: Very fast.
- */
- boolean isClass(int objectId);
-
- /**
- * Returns true if the object by this id is a class loader.
- * <p>
- * Performance: Very fast.
- */
- boolean isClassLoader(int objectId);
-
- /**
- * Returns true if the object by this id is an array.
- * <p>
- * Performance: Very fast.
- */
- boolean isArray(int objectId);
-
- /**
- * Returns true if the object by this id is a garbage collection root.
- * <p>
- * Performance: Very fast.
- */
- boolean isGCRoot(int objectId);
-
- /**
- * Map object id (snapshot internal identity assigned during parsing) to
- * object address (memory address where the object was stored).
- * <p>
- * Performance: Fast - in memory.
- *
- * @param objectId id of object you want the address for
- * @return object address
- * @throws SnapshotException
- */
- public long mapIdToAddress(int objectId) throws SnapshotException;
-
- /**
- * Map object address (memory address where the object was stored) to object
- * id (snapshot internal identity assigned during parsing).
- * <p>
- * Performance: Fast - binary search in memory.
- *
- * @param objectAddress address of object you want the id for
- * @return object id
- * @throws SnapshotException
- */
- public int mapAddressToId(long objectAddress) throws SnapshotException;
-
- /**
- * Dispose the whole snapshot.
- * <p>
- * Please call this method prior to dropping the last reference to the
- * snapshot as this method ensures the proper return of all resources (e.g.
- * main memory, file and socket handles...). After calling this method the
- * snapshot can't be used anymore.
- */
- public void dispose();
-
- /**
- * Get additional JVM information, if available.
- * <p>
- *
- * @return SnapshotAddons - extended information, e.g. perm info, OoM stack
- * trace info, JVM arguments, etc.
- * @throws SnapshotException
- */
- public <A> A getSnapshotAddons(Class<A> addon) throws SnapshotException;
-
- /**
- * Get a the stack trace information for a given thread object, if thread
- * stack information is available in this snapshot.
- * <p>
- *
- * @return IThreadStack - an object representing the call stack of the
- * thread. Returns null if no info is available for the object, or
- * no stack info is available at all
- * @throws SnapshotException
- * @since 0.8
- */
- public IThreadStack getThreadStack(int objectId) throws SnapshotException;
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/MultiplePathsFromGCRootsClassRecord.java b/src/main/java/org/eclipse/mat/snapshot/MultiplePathsFromGCRootsClassRecord.java
deleted file mode 100644
index 0165d3c..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/MultiplePathsFromGCRootsClassRecord.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.HashMapIntObject;
-import org.eclipse.mat.collect.SetInt;
-import org.eclipse.mat.snapshot.model.IClass;
-
-public class MultiplePathsFromGCRootsClassRecord {
- private List<int[]> paths = new ArrayList<int[]>();
- private SetInt distinctObjects;
- private int level;
- private IClass clazz;
- private long referencedSize = -1;
- private ISnapshot snapshot;
- private boolean fromRoots;
-
- public MultiplePathsFromGCRootsClassRecord(IClass clazz, int level, boolean fromRoots,
- ISnapshot snapshot) {
- this.clazz = clazz;
- this.level = level;
- this.fromRoots = fromRoots;
- this.snapshot = snapshot;
- }
-
- public MultiplePathsFromGCRootsClassRecord[] nextLevel() throws SnapshotException {
- int nextLevel = level + 1;
- if (nextLevel < 0) return null;
-
- HashMapIntObject<MultiplePathsFromGCRootsClassRecord> nextLevelRecords =
- new HashMapIntObject<MultiplePathsFromGCRootsClassRecord>();
- for (int[] path : paths) {
- if (path != null) {
- int newIndex = fromRoots ? path.length - nextLevel - 1 : nextLevel;
- // check if one of the ends is reached
- if (newIndex < 0 || newIndex >= path.length) {
- continue;
- }
- IClass clazz = snapshot.getClassOf(path[newIndex]);
- MultiplePathsFromGCRootsClassRecord record = nextLevelRecords.get(clazz.getObjectId());
- if (record == null) {
- record = new MultiplePathsFromGCRootsClassRecord(clazz, nextLevel, fromRoots, snapshot);
- nextLevelRecords.put(clazz.getObjectId(), record);
- }
- record.addPath(path);
- }
- }
-
- return nextLevelRecords.getAllValues(new MultiplePathsFromGCRootsClassRecord[0]);
- }
-
- /**
- * This method is used only when the record is built. Adds one path to the
- * set of paths
- */
- public void addPath(int[] path) {
- paths.add(path);
- }
-
- /**
- * Get all the paths going through the object (getObjectId())
- *
- * @return List<int[]> each element in the list is an int[] representing a
- * path
- */
- public List<int[]> getPaths() {
- return paths;
- }
-
- /**
- * Get the number of paths going through this object
- */
- public int getCount() {
- return paths.size();
- }
-
- /**
- * Get the number of distinct objects of this class
- */
- public int getDistinctCount() {
- if (distinctObjects == null) // lazy init
- {
- distinctObjects = new SetInt();
- for (int[] path : paths) {
- int index = fromRoots ? path.length - level - 1 : level;
- distinctObjects.add(path[index]);
- }
- }
- return distinctObjects.size();
- }
-
- /**
- * Get the total net heap size of all referenced objects (see
- * getReferencedObjects())
- *
- * @return - the total heap size of all referenced objects
- * @throws SnapshotException
- */
- public long getReferencedHeapSize() throws SnapshotException {
- if (referencedSize == -1) {
- referencedSize = snapshot.getHeapSize(getReferencedObjects());
- }
- return referencedSize;
- }
-
- /**
- * Get the "end" objects for each path. This is equal to getting all the
- * paths and looking at their element [0]
- *
- * @return - an array with all the objects at the end of the paths
- */
- public int[] getReferencedObjects() {
- int[] result = new int[paths.size()];
-
- int i = 0;
- for (int[] path : paths) {
- result[i++] = path[0];
- }
-
- return result;
- }
-
- public static Comparator<MultiplePathsFromGCRootsClassRecord> getComparatorByNumberOfReferencedObjects() {
- return new Comparator<MultiplePathsFromGCRootsClassRecord>() {
-
- public int compare(MultiplePathsFromGCRootsClassRecord o1,
- MultiplePathsFromGCRootsClassRecord o2) {
- if (o1.paths.size() < o2.paths.size()) return 1;
- if (o1.paths.size() > o2.paths.size()) return -1;
- return 0;
- }
- };
- }
-
- /**
- * Returns a Comparator ordering the records descending by the total size of
- * referenced objects.
- */
- public static Comparator<MultiplePathsFromGCRootsClassRecord> getComparatorByReferencedHeapSize() {
- return new Comparator<MultiplePathsFromGCRootsClassRecord>() {
-
- public int compare(MultiplePathsFromGCRootsClassRecord o1,
- MultiplePathsFromGCRootsClassRecord o2) {
- try {
- if (o1.getReferencedHeapSize() < o2.getReferencedHeapSize()) return 1;
- if (o1.getReferencedHeapSize() > o2.getReferencedHeapSize()) return -1;
- return 0;
- } catch (SnapshotException e) {
- // $JL-EXC$
- return 0;
- }
- }
- };
- }
-
- public IClass getClazz() {
- return clazz;
- }
-
- public boolean isFromRoots() {
- return fromRoots;
- }
-
- public int getLevel() {
- return level;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/MultiplePathsFromGCRootsRecord.java b/src/main/java/org/eclipse/mat/snapshot/MultiplePathsFromGCRootsRecord.java
deleted file mode 100644
index 9019308..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/MultiplePathsFromGCRootsRecord.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.collect.HashMapIntObject;
-
-/**
- * This class represents a set of paths from the GC roots to different objects,
- * which go through one and the same object.
- */
-public class MultiplePathsFromGCRootsRecord {
- final ISnapshot snapshot;
- final int objectId;
- final int level;
-
- List<int[]> paths;
- long referencedSize = -1;
- long referencedRetainedSize;
-
- /**
- * Get the total retained heap size of the referenced objects
- */
- public long getReferencedRetainedSize() {
- return referencedRetainedSize;
- }
-
- /**
- * Set the retained heap size of the referenced objects
- */
- public void setReferencedRetainedSize(long referencedRetainedSize) {
- this.referencedRetainedSize = referencedRetainedSize;
- }
-
- /**
- * A constructor to create the record
- *
- * @param objectId - the ID of the object which is common for all the paths
- * @param level - the level (depth) in the paths where this objects appears
- * @param snapshot - an ISnapshot object used for further calculation
- */
- public MultiplePathsFromGCRootsRecord(int objectId, int level, ISnapshot snapshot) {
- this.level = level;
- this.objectId = objectId;
- paths = new ArrayList<int[]>();
- this.snapshot = snapshot;
- }
-
- /**
- * Returns the next level of the paths. For all paths going through this
- * object the next objects in the paths are taken and grouped again (i.e.
- * the lenght of the returned array will be equal to the number of different
- * objects at the next depth level of the paths). The direction is from the
- * GC roots to the objects
- *
- * @return MultiplePathsFromGCRootsRecord[] Each record in the result
- * represents again paths going through one and the same object
- */
- public MultiplePathsFromGCRootsRecord[] nextLevel() {
- int new_level = level + 1;
- HashMapIntObject<MultiplePathsFromGCRootsRecord> nextLevelRecords =
- new HashMapIntObject<MultiplePathsFromGCRootsRecord>();
- for (int[] path : paths) {
- if (path != null && (path.length - new_level - 1 >= 0)) {
- MultiplePathsFromGCRootsRecord record =
- nextLevelRecords.get(path[path.length - new_level - 1]);
- if (record == null) {
- record = new MultiplePathsFromGCRootsRecord(path[path.length - new_level - 1], new_level,
- snapshot);
- nextLevelRecords.put(path[path.length - new_level - 1], record);
- }
- record.addPath(path);
- }
- }
-
- return nextLevelRecords.getAllValues(new MultiplePathsFromGCRootsRecord[0]);
- }
-
- /**
- * This method is used only when the record is built. Adds one path to the
- * set of paths
- */
- public void addPath(int[] path) {
- paths.add(path);
- }
-
- /**
- * Get all the paths going through the object (getObjectId())
- *
- * @return List<int[]> each element in the list is an int[] representing a
- * path
- */
- public List<int[]> getPaths() {
- return paths;
- }
-
- /**
- * Get the id of the object which is common for all the paths
- */
- public int getObjectId() {
- return objectId;
- }
-
- /**
- * Get the number of paths going through this object
- */
- public int getCount() {
- return paths.size();
- }
-
- /**
- * Get the level of this record
- */
- public int getLevel() {
- return level;
- }
-
- /**
- * Get the "end" objects for each path. This is equal to getting all the
- * paths and looking at their element [0]
- *
- * @return - an array with all the objects at the end of the paths
- */
- public int[] getReferencedObjects() {
- int[] result = new int[paths.size()];
-
- int i = 0;
- for (int[] path : paths) {
- result[i++] = path[0];
- }
-
- return result;
- }
-
- /**
- * Get the total net heap size of all referenced objects (see
- * getReferencedObjects())
- *
- * @return - the total heap size of all referenced objects
- * @throws SnapshotException
- */
- public long getReferencedHeapSize() throws SnapshotException {
- if (referencedSize == -1) {
- referencedSize = snapshot.getHeapSize(getReferencedObjects());
- }
- return referencedSize;
- }
-
- /**
- * Returns a Comparator ordering the records descending by the number of
- * referenced objects.
- */
- public static Comparator<MultiplePathsFromGCRootsRecord> getComparatorByNumberOfReferencedObjects() {
- return new Comparator<MultiplePathsFromGCRootsRecord>() {
-
- public int compare(MultiplePathsFromGCRootsRecord o1, MultiplePathsFromGCRootsRecord o2) {
- if (o1.paths.size() < o2.paths.size()) return 1;
- if (o1.paths.size() > o2.paths.size()) return -1;
- return 0;
- }
- };
- }
-
- /**
- * Returns a Comparator ordering the records descending by the total size of
- * referenced objects.
- */
- public static Comparator<MultiplePathsFromGCRootsRecord> getComparatorByReferencedHeapSize() {
- return new Comparator<MultiplePathsFromGCRootsRecord>() {
-
- public int compare(MultiplePathsFromGCRootsRecord o1, MultiplePathsFromGCRootsRecord o2) {
- try {
- if (o1.getReferencedHeapSize() < o2.getReferencedHeapSize()) return 1;
- if (o1.getReferencedHeapSize() > o2.getReferencedHeapSize()) return -1;
- return 0;
- } catch (SnapshotException e) {
- // $JL-EXC$
- return 0;
- }
- }
- };
- }
-
- /**
- * Returns a Comparator ordering the records descending by the total size of
- * referenced objects.
- */
- public static Comparator<MultiplePathsFromGCRootsRecord> getComparatorByReferencedRetainedSize() {
- return new Comparator<MultiplePathsFromGCRootsRecord>() {
-
- public int compare(MultiplePathsFromGCRootsRecord o1, MultiplePathsFromGCRootsRecord o2) {
- if (o1.getReferencedRetainedSize() < o2.getReferencedRetainedSize()) return 1;
- if (o1.getReferencedRetainedSize() > o2.getReferencedRetainedSize()) return -1;
- return 0;
- }
- };
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/PathsFromGCRootsTree.java b/src/main/java/org/eclipse/mat/snapshot/PathsFromGCRootsTree.java
deleted file mode 100644
index c974d59..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/PathsFromGCRootsTree.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot;
-
-import java.util.HashMap;
-
-/**
- * This class holds the paths from one single object to its GC roots.
- *
- * @noinstantiate
- */
-public final class PathsFromGCRootsTree {
- private int ownId;
- private int[] objectIds;
- private HashMap<Integer, PathsFromGCRootsTree> objectInboundReferers;
-
- public PathsFromGCRootsTree(int ownId,
- HashMap<Integer, PathsFromGCRootsTree> objectInboundReferers, int[] objectIds) {
- this.ownId = ownId;
- this.objectInboundReferers = objectInboundReferers;
- this.objectIds = objectIds;
- }
-
- /**
- * Get object being the root for this tree.
- *
- * @return object being the root for this tree
- */
- public int getOwnId() {
- return ownId;
- }
-
- /**
- * Get referencing objects.
- *
- * @return referencing objects
- */
- public int[] getObjectIds() {
- return objectIds;
- }
-
- /**
- * Get sub tree for a referencing object.
- *
- * @param objId referencing object from which on the sub tree is requested
- * @return sub tree for a referencing object
- */
- public PathsFromGCRootsTree getBranch(int objId) {
- return objectInboundReferers.get(objId);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/SnapshotFormat.java b/src/main/java/org/eclipse/mat/snapshot/SnapshotFormat.java
deleted file mode 100644
index f718cac..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/SnapshotFormat.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot;
-
-/**
- * @noinstantiate
- */
-public class SnapshotFormat {
- private String name;
- private String[] fileExtensions;
-
- public SnapshotFormat(String name, String[] fileExtensions) {
- this.fileExtensions = fileExtensions;
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public String[] getFileExtensions() {
- return fileExtensions;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/SnapshotInfo.java b/src/main/java/org/eclipse/mat/snapshot/SnapshotInfo.java
deleted file mode 100644
index 1929fd6..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/SnapshotInfo.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Class describing an {@link ISnapshot}. Each snapshot has some core data, like
- * the date when it was acquired/parsed, the number of objects inside... This
- * data is available with the snapshot info which is usually serialized along
- * with the snapshot.
- */
-public class SnapshotInfo implements Serializable {
- private static final long serialVersionUID = 4L;
-
- protected String path;
- protected String prefix;
- protected String jvmInfo;
- protected int identifierSize;
- protected Date creationDate;
- protected int numberOfObjects;
- protected int numberOfGCRoots;
- protected int numberOfClasses;
- protected int numberOfClassLoaders;
- protected long usedHeapSize;
- protected Map<String, Serializable> properties;
-
- /**
- * Construct a snapshot info.
- *
- * @param path path from where the snapshot was acquired
- * @param jvmInfo version of the JVM from which it was acquired
- * @param identifierSize size of the internal identifiers in the heap dump, i.e. 32 or
- * 64 bit
- * @param creationDate date when the snapshot was acquired/parsed
- * @param numberOfObjects number of Java objects found in the snapshot
- * @param numberOfGCRoots number of GC roots found in the snapshot
- * @param numberOfClasses number of Java Classes found in the snapshot
- * @param numberOfClassLoaders number of ClassLoaders found in the snapshot
- * @param usedHeapSize number of bytes used in the heap (the allocated memory may be
- * higher)
- */
- public SnapshotInfo(String path, String prefix, String jvmInfo, int identifierSize,
- Date creationDate, int numberOfObjects, int numberOfGCRoots, int numberOfClasses,
- int numberOfClassLoaders, long usedHeapSize) {
- this.path = path;
- this.prefix = prefix;
- this.jvmInfo = jvmInfo;
- this.identifierSize = identifierSize;
- this.creationDate = creationDate != null ? new Date(creationDate.getTime()) : null;
- this.numberOfObjects = numberOfObjects;
- this.numberOfGCRoots = numberOfGCRoots;
- this.numberOfClasses = numberOfClasses;
- this.numberOfClassLoaders = numberOfClassLoaders;
- this.usedHeapSize = usedHeapSize;
- this.properties = new HashMap<String, Serializable>();
- }
-
- @Deprecated
- public SnapshotInfo(String path, String jvmInfo, int identifierSize, Date creationDate,
- int numberOfObjects, int numberOfGCRoots, int numberOfClasses, int numberOfClassLoaders,
- long usedHeapSize) {
- this(path, prefix(path), jvmInfo, identifierSize, creationDate, numberOfObjects,
- numberOfGCRoots, numberOfClasses, numberOfClassLoaders, usedHeapSize);
- }
-
- private static String prefix(String path) {
- int p = path.lastIndexOf('.');
- return p >= 0 ? path.substring(0, p + 1) : path + '.';
- }
-
- public Serializable getProperty(String name) {
- return properties.get(name);
- }
-
- public Serializable setProperty(String name, Serializable value) {
- return properties.put(name, value);
- }
-
- /**
- * Get the absolute path of the heap dump file.
- *
- * @return absolute path of the heap dump file.
- */
- public String getPath() {
- return path;
- }
-
- /**
- * Get the common prefix used to name all additional (e.g. index) files. The
- * prefix includes the directory path.
- *
- * @return common prefix used to name additional files
- */
- public String getPrefix() {
- return prefix;
- }
-
- /**
- * Get version of the JVM from which it was acquired.
- *
- * @return version of the JVM from which it was acquired
- */
- public String getJvmInfo() {
- return jvmInfo;
- }
-
- /**
- * Get size of the internal identifiers in the heap dump, i.e. 32 or 64 bit.
- *
- * @return size of the internal identifiers in the heap dump, i.e. 32 or 64
- * bit
- */
- public int getIdentifierSize() {
- return identifierSize;
- }
-
- /**
- * Get date when the snapshot was acquired/parsed.
- *
- * @return creation date, or <code>null</code> if the creation date is not
- * known
- */
- public Date getCreationDate() {
- return creationDate != null ? new Date(creationDate.getTime()) : null;
- }
-
- /**
- * Get number of Java objects found in the snapshot.
- *
- * @return number of Java objects found in the snapshot
- */
- public int getNumberOfObjects() {
- return numberOfObjects;
- }
-
- /**
- * Get number of GC roots found in the snapshot.
- *
- * @return number of GC roots found in the snapshot
- */
- public int getNumberOfGCRoots() {
- return numberOfGCRoots;
- }
-
- /**
- * Get number of Java Classes found in the snapshot.
- *
- * @return number of Java Classes found in the snapshot
- */
- public int getNumberOfClasses() {
- return numberOfClasses;
- }
-
- /**
- * Get number of ClassLoaders found in the snapshot
- *
- * @return number of ClassLoaders found in the snapshot
- */
- public int getNumberOfClassLoaders() {
- return numberOfClassLoaders;
- }
-
- /**
- * Get number of bytes used in the heap (the allocated memory may be higher)
- *
- * @return number of bytes used in the heap (the allocated memory may be
- * higher)
- */
- public long getUsedHeapSize() {
- return usedHeapSize;
- }
-
- @SuppressWarnings("nls") @Override public String toString() {
- StringBuilder summary = new StringBuilder();
- summary.append("Path: ");
- summary.append(path);
- summary.append("\r\nJVM Info: ");
- summary.append(jvmInfo);
- summary.append("\r\nIdentifier Size: ");
- summary.append(identifierSize);
- summary.append("\r\nCreation Date: ");
- summary.append(creationDate);
- summary.append("\r\nNumber of Objects: ");
- summary.append(numberOfObjects);
- summary.append("\r\nNumber of GC roots: ");
- summary.append(numberOfGCRoots);
- summary.append("\r\nNumber of Classes: ");
- summary.append(numberOfClasses);
- summary.append("\r\nNumber of ClassLoaders: ");
- summary.append(numberOfClassLoaders);
- summary.append("\r\nUsed Heap Size: ");
- summary.append(usedHeapSize);
- return summary.toString();
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/extension/IClassSpecificNameResolver.java b/src/main/java/org/eclipse/mat/snapshot/extension/IClassSpecificNameResolver.java
deleted file mode 100644
index 33a700f..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/extension/IClassSpecificNameResolver.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.extension;
-
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.snapshot.model.IObject;
-
-/**
- * Interface describing a name resolver for objects of specific classes (found
- * in an snapshot), e.g. String (where the char[] is evaluated) or as specific
- * class loader (where the appropriate field holding its name and thereby
- * deployment unit is evaluated). Objects of this interface need to be
- * registered with the <code>nameResolver</code> extension point.
- */
-public interface IClassSpecificNameResolver {
- /**
- * Resolve the name for snapshot object.
- *
- * @param object object for which the name should be resolved
- * @return name for snapshot object
- * @throws SnapshotException
- */
- public String resolve(IObject object) throws SnapshotException;
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/extension/Subject.java b/src/main/java/org/eclipse/mat/snapshot/extension/Subject.java
deleted file mode 100644
index a7a3fb6..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/extension/Subject.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.extension;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-@Target({ TYPE }) @Retention(RUNTIME) public @interface Subject {
- String value();
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/extension/Subjects.java b/src/main/java/org/eclipse/mat/snapshot/extension/Subjects.java
deleted file mode 100644
index 1a2e07c..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/extension/Subjects.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.extension;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-@Target({ TYPE }) @Retention(RUNTIME) public @interface Subjects {
- String[] value();
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/Field.java b/src/main/java/org/eclipse/mat/snapshot/model/Field.java
deleted file mode 100644
index e3c7340..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/Field.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-import java.io.Serializable;
-
-/**
- * Describes a member variable, i.e. name, signature and value.
- */
-public final class Field extends FieldDescriptor implements Serializable {
- private static final long serialVersionUID = 2L;
-
- protected Object value;
-
- public Field(String name, int type, Object value) {
- super(name, type);
- this.value = value;
- }
-
- public Object getValue() {
- return value;
- }
-
- public void setValue(Object object) {
- value = object;
- }
-
- public String toString() {
- return type + " " + name + ": \t" + value; //$NON-NLS-1$//$NON-NLS-2$
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/FieldDescriptor.java b/src/main/java/org/eclipse/mat/snapshot/model/FieldDescriptor.java
deleted file mode 100644
index 4e8b074..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/FieldDescriptor.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-import java.io.Serializable;
-
-/**
- * Describes a field of an object, i.e. its name and signature.
- */
-public class FieldDescriptor implements Serializable {
- private static final long serialVersionUID = 2L;
-
- protected String name;
- protected int type;
-
- public FieldDescriptor(String name, int type) {
- this.name = name;
- this.type = type;
- }
-
- public String getName() {
- return name;
- }
-
- public int getType() {
- return type;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setType(int type) {
- this.type = type;
- }
-
- public String getVerboseSignature() {
- if (type == IObject.Type.OBJECT) return "ref"; //$NON-NLS-1$
-
- String t = IPrimitiveArray.TYPE[type];
- return t.substring(0, t.length() - 2);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/GCRootInfo.java b/src/main/java/org/eclipse/mat/snapshot/model/GCRootInfo.java
deleted file mode 100644
index b51c45f..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/GCRootInfo.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-import java.io.Serializable;
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.util.MessageUtil;
-
-/**
- * Describes a garbage collection root.
- */
-abstract public class GCRootInfo implements Serializable {
- private static final long serialVersionUID = 2L;
-
- /**
- * Reasons why an heap object is a garbage collection root.
- */
- public interface Type {
- int UNKNOWN = 1;
- /**
- * Class loaded by system class loader, e.g. java.lang.String
- */
- int SYSTEM_CLASS = 2;
- /**
- * Local variable in native code
- */
- int NATIVE_LOCAL = 4;
- /**
- * Global variable in native code
- */
- int NATIVE_STATIC = 8;
- /**
- * Started but not stopped threads
- */
- int THREAD_BLOCK = 16;
- /**
- * Everything you have called wait() or notify() on or you have
- * synchronized on
- */
- int BUSY_MONITOR = 32;
- /**
- * Local variable, i.e. method input parameters or locally created
- * objects of methods still on the stack of a thread
- */
- int JAVA_LOCAL = 64;
- /**
- * In or out parameters in native code; frequently seen as some methods
- * have native parts and the objects handled as method parameters become
- * GC roots, e.g. parameters used for file/network I/O methods or
- * reflection
- */
- int NATIVE_STACK = 128;
- int THREAD_OBJ = 256;
- /**
- * An object which is a queue awaiting its finalizer to be run
- */
- int FINALIZABLE = 512;
- /**
- * An object which has a finalize method, but has not been finalized and
- * is not yet on the finalizer queue
- */
- int UNFINALIZED = 1024;
- /**
- * An object which is unreachable from any other root, but has been
- * marked as a root by MAT to retain objects which otherwise would not
- * be included in the analysis
- */
- int UNREACHABLE = 2048;
- }
-
- private final static String[] TYPE_STRING = new String[] {
- MessageUtil.format(Messages.GCRootInfo_Unkown), //
- MessageUtil.format(Messages.GCRootInfo_SystemClass), //
- MessageUtil.format(Messages.GCRootInfo_JNILocal), //
- MessageUtil.format(Messages.GCRootInfo_JNIGlobal), //
- MessageUtil.format(Messages.GCRootInfo_ThreadBlock), //
- MessageUtil.format(Messages.GCRootInfo_BusyMonitor), //
- MessageUtil.format(Messages.GCRootInfo_JavaLocal), //
- MessageUtil.format(Messages.GCRootInfo_NativeStack), //
- MessageUtil.format(Messages.GCRootInfo_Thread), //
- MessageUtil.format(Messages.GCRootInfo_Finalizable), //
- MessageUtil.format(Messages.GCRootInfo_Unfinalized),
- MessageUtil.format(Messages.GCRootInfo_Unreachable)
- };
-
- protected int objectId;
- private long objectAddress;
- protected int contextId;
- private long contextAddress;
- private int type;
-
- public GCRootInfo(long objectAddress, long contextAddress, int type) {
- this.objectAddress = objectAddress;
- this.contextAddress = contextAddress;
- this.type = type;
- }
-
- public int getObjectId() {
- return objectId;
- }
-
- public long getObjectAddress() {
- return objectAddress;
- }
-
- public long getContextAddress() {
- return contextAddress;
- }
-
- public int getContextId() {
- return contextId;
- }
-
- public int getType() {
- return type;
- }
-
- public static String getTypeAsString(int type) {
- for (int i = 0; i < TYPE_STRING.length; i++)
- if (((1 << i) & type) != 0) return TYPE_STRING[i];
-
- return null;
- }
-
- public static String getTypeSetAsString(GCRootInfo[] roots) {
- int typeSet = 0;
- for (GCRootInfo info : roots) {
- typeSet |= info.getType();
- }
-
- StringBuilder buf = new StringBuilder();
- boolean first = true;
- for (int i = 0; i < TYPE_STRING.length; i++) {
- if (((1 << i) & typeSet) != 0) {
- if (!first) {
- buf.append(", "); //$NON-NLS-1$
- } else {
- // Performance optimization - if there is only one bit set
- // return the type string without building a new string.
- if ((1 << i) == typeSet) {
- return TYPE_STRING[i];
- }
- first = false;
- }
- buf.append(TYPE_STRING[i]);
- }
- }
- return buf.toString();
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/IArray.java b/src/main/java/org/eclipse/mat/snapshot/model/IArray.java
deleted file mode 100644
index c95a514..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/IArray.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-/**
- * Interface for an array object in the heap dump.
- *
- * @noimplement
- */
-public interface IArray extends IObject {
- /**
- * Returns the length of the object.
- */
- public int getLength();
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/IClass.java b/src/main/java/org/eclipse/mat/snapshot/model/IClass.java
deleted file mode 100644
index edf886a..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/IClass.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.util.IProgressListener;
-
-/**
- * Interface for a class instance in the heap dump.
- *
- * @noimplement
- */
-public interface IClass extends IObject {
- String JAVA_LANG_CLASS = "java.lang.Class"; //$NON-NLS-1$
- String JAVA_LANG_CLASSLOADER = "java.lang.ClassLoader"; //$NON-NLS-1$
-
- /**
- * Returns the fully qualified class name of this class.
- */
- public String getName();
-
- /**
- * Returns the number of instances of this class present in the heap dump.
- */
- public int getNumberOfObjects();
-
- /**
- * Ids of all instances of this class (an empty array if there are no instances of the class)
- */
- public int[] getObjectIds() throws SnapshotException;
-
- /**
- * Returns the id of the class loader which loaded this class.
- */
- public int getClassLoaderId();
-
- /**
- * Returns the address of the class loader which loaded this class.
- */
- public long getClassLoaderAddress();
-
- /**
- * Returns field descriptors for all member variables of instances of this
- * class.
- */
- public List<FieldDescriptor> getFieldDescriptors();
-
- /**
- * Returns the static fields and it values.
- */
- public List<Field> getStaticFields();
-
- /**
- * Returns the heap size of one instance of this class. Not valid if this
- * class represents an array.
- */
- public int getHeapSizePerInstance();
-
- /**
- * Returns the retained size of all objects of this instance including the
- * class instance.
- */
- public long getRetainedHeapSizeOfObjects(boolean calculateIfNotAvailable,
- boolean calculateMinRetainedSize, IProgressListener listener) throws SnapshotException;
-
- /**
- * Returns the id of the super class. -1 if it has no super class, i.e. if
- * it is java.lang.Object.
- */
- public int getSuperClassId();
-
- /**
- * Returns the super class.
- */
- public IClass getSuperClass();
-
- /**
- * Returns true if the class has a super class.
- */
- public boolean hasSuperClass();
-
- /**
- * Returns the direct sub-classes.
- */
- public List<IClass> getSubclasses();
-
- /**
- * Returns all sub-classes including sub-classes of its sub-classes.
- */
- public List<IClass> getAllSubclasses();
-
- public boolean doesExtend(String className) throws SnapshotException;
-
- /**
- * Returns true if the class is an array class.
- */
- public boolean isArrayType();
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/IClassLoader.java b/src/main/java/org/eclipse/mat/snapshot/model/IClassLoader.java
deleted file mode 100644
index f43e20f..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/IClassLoader.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.util.IProgressListener;
-
-/**
- * An interface for class loader.
- *
- * @noimplement
- */
-public interface IClassLoader extends IInstance {
- /**
- * Returns the retained size of all objects and classes loaded by this class
- * loader.
- */
- long getRetainedHeapSizeOfObjects(boolean calculateIfNotAvailable,
- boolean calculateMinRetainedSize, IProgressListener listener) throws SnapshotException;
-
- /**
- * Returns the classes defined by this class loader instance.
- */
- List<IClass> getDefinedClasses() throws SnapshotException;
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/IInstance.java b/src/main/java/org/eclipse/mat/snapshot/model/IInstance.java
deleted file mode 100644
index ab5a084..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/IInstance.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-import java.util.List;
-
-/**
- * Interface for a plain vanilla object instance in the heap dump.
- *
- * @noimplement
- */
-public interface IInstance extends IObject {
- /**
- * Returns all fields of the object.
- * <p>
- * Fields are ordered in such a way, that first fields defined in the
- * current class and then fields of the super class and its super classes
- * are returned. This order is important to know, if a class declares a
- * field by the same name as the class it inherits from.
- */
- public List<Field> getFields();
-
- /**
- * Returns the field identified by the name.
- * <p>
- * If declares a member variable by the same name as the parent class does,
- * then the result of this method is undefined.
- */
- public Field getField(String name);
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/IObject.java b/src/main/java/org/eclipse/mat/snapshot/model/IObject.java
deleted file mode 100644
index ff462de..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/IObject.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-import java.io.Serializable;
-import java.util.List;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.snapshot.ISnapshot;
-
-/**
- * Base interface for all objects found in a snapshot. Other model interfaces
- * derive from this interface, e.g. for classes, plain objects, object arrays,
- * primitive arrays...
- *
- * @noimplement
- */
-public interface IObject extends Serializable {
- /**
- * The type of the primitive array.
- */
- public interface Type {
- int OBJECT = 2;
-
- int BOOLEAN = 4;
- int CHAR = 5;
- int FLOAT = 6;
- int DOUBLE = 7;
- int BYTE = 8;
- int SHORT = 9;
- int INT = 10;
- int LONG = 11;
- }
-
- /**
- * Get id for the snapshot object. The id is not the address, but an
- * internally assigned number fitting into an <code>int</code> (this helps
- * reducing the memory footprint of the snapshot considerably - addresses
- * are only used for visualization purposes).
- *
- * @return id for the snapshot object
- */
- public int getObjectId();
-
- /**
- * Get address for the snapshot object. This is the address at which the
- * object was stored in memory. Use the address only for visualization
- * purposes and try to use the id wherever possible as the snapshot API is
- * optimized to handle ids and not addresses. Addresses are bigger (
- * <code>long</code>), have no consecutive order (with gaps), and are not
- * used for hashing.
- *
- * @return address for the snapshot object
- */
- public long getObjectAddress();
-
- /**
- * Get class snapshot object this object is an instance of.
- *
- * @return class snapshot object this object is an instance of
- */
- public IClass getClazz();
-
- /**
- * Get used heap size of this object.
- *
- * @return used heap size of this object
- */
- public int getUsedHeapSize();
-
- /**
- * Get retained heap size of this object.
- *
- * @return retained heap size of this object (returns 0 if the dominator
- * tree wasn't calculated for the corresponding snapshot)
- */
- public long getRetainedHeapSize();
-
- /**
- * Get technical name of this object which is something like class@address.
- *
- * @return technical name of this object which is something like class@address
- */
- public String getTechnicalName();
-
- /**
- * Get class specific name of this object which depends on the availability
- * of the appropriate name resolver, e.g. for a String the value of the
- * char[].
- *
- * @return class specific name of the given snapshot object or null if it
- * can't be resolved
- */
- public String getClassSpecificName();
-
- /**
- * Get concatenation of {@link #getTechnicalName()} and
- * {@link #getClassSpecificName()}.
- *
- * @return concatenation of {@link #getTechnicalName()} and
- * {@link #getClassSpecificName()}
- */
- public String getDisplayName();
-
- /**
- * Get list of snapshot objects referenced from this snapshot object with
- * the name of the field over which it was referenced.
- *
- * @return list of snapshot objects referenced from this snapshot object
- * with the name of the field over which it was referenced
- */
- public List<NamedReference> getOutboundReferences();
-
- /**
- * Resolves and returns the value of a field specified by a dot notation. If
- * the field is a primitive type, the value the returns the corresponding
- * object wrapper, e.g. a java.lang.Boolean is returned for a field of type
- * boolean. If the field is an object reference, the corresponding IObject
- * is returned.
- * <p>
- * The field can be specified using the dot notation, i.e. object references
- * are followed and its fields are evaluated. If any of the object
- * references is null, null is returned.
- *
- * @param field the field name in dot notation
- * @return the value of the field
- */
- public Object resolveValue(String field) throws SnapshotException;
-
- /**
- * Get {@link GCRootInfo} if the object is a garbage collection root or null
- * otherwise. An object may or may not be a garbage collection root, it may
- * even be one for multiple reasons (described in the {@link GCRootInfo}
- * object).
- *
- * @return {@link GCRootInfo} if the object is a garbage collection root or
- * null otherwise
- */
- public GCRootInfo[] getGCRootInfo() throws SnapshotException;
-
- /**
- * Returns the snapshot from which this object has been read.
- *
- * @return the snapshot from which this object has been read.
- */
- public ISnapshot getSnapshot();
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/IObjectArray.java b/src/main/java/org/eclipse/mat/snapshot/model/IObjectArray.java
deleted file mode 100644
index c056d75..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/IObjectArray.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-/**
- * Marker interface to represent object arrays in the heap dump.
- *
- * @noimplement
- */
-public interface IObjectArray extends IArray {
- /**
- * Get an array with the object addresses. 0 indicate <code>null</code>
- * values in the array.
- */
- long[] getReferenceArray();
-
- /**
- * Get an array with the object addresses, beginning at <code>offset</code>
- * and <code>length</code> number of elements.
- */
- long[] getReferenceArray(int offset, int length);
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/IPrimitiveArray.java b/src/main/java/org/eclipse/mat/snapshot/model/IPrimitiveArray.java
deleted file mode 100644
index d1aae88..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/IPrimitiveArray.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-/**
- * Interface for primitive arrays in the heap dump.
- *
- * @noimplement
- */
-public interface IPrimitiveArray extends IArray {
- /**
- * Primitive signatures.
- */
- public static final byte[] SIGNATURES = {
- -1, -1, -1, -1, (byte) 'Z', (byte) 'C', (byte) 'F', (byte) 'D', (byte) 'B', (byte) 'S',
- (byte) 'I', (byte) 'J'
- };
-
- /**
- * Element sizes inside the array.
- */
- public static final int[] ELEMENT_SIZE = { -1, -1, -1, -1, 1, 2, 4, 8, 1, 2, 4, 8 };
-
- /**
- * Display string of the type.
- */
- @SuppressWarnings("nls") public static final String[] TYPE = {
- null, null, null, null, "boolean[]", "char[]", "float[]", "double[]", "byte[]", "short[]",
- "int[]", "long[]"
- };
-
- /**
- * Java component type of the primitive array.
- */
- public static final Class<?>[] COMPONENT_TYPE = {
- null, null, null, null, boolean.class, char.class, float.class, double.class, byte.class,
- short.class, int.class, long.class
- };
-
- /**
- * Returns the {@link IObject.Type} of the primitive array.
- */
- public int getType();
-
- /**
- * Returns the component type of the array.
- */
- public Class<?> getComponentType();
-
- /**
- * Returns the Object at a given index.
- */
- public Object getValueAt(int index);
-
- /**
- * Get the primitive Java array. The return value can be casted into the
- * correct component type, e.g.
- *
- * <pre>
- * if (char.class == array.getComponentType())
- * {
- * char[] content = (char[]) array.getValueArray();
- * System.out.println(content.length);
- * }
- * </pre>
- *
- * The return value must not be modified because it is cached by the heap
- * dump adapter. This method does not return a copy of the array for
- * performance reasons.
- */
- public Object getValueArray();
-
- /**
- * Get the primitive Java array, beginning at <code>offset</code> and
- * <code>length</code> number of elements.
- * <p>
- * The return value must not be modified because it is cached by the heap
- * dump adapter. This method does not return a copy of the array for
- * performance reasons.
- */
- public Object getValueArray(int offset, int length);
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/IStackFrame.java b/src/main/java/org/eclipse/mat/snapshot/model/IStackFrame.java
deleted file mode 100644
index f7a4395..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/IStackFrame.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-/**
- * May be subject of change
- *
- * @noimplement
- * @since 0.8
- */
-public interface IStackFrame {
-
- /**
- * Returns the object IDs of all objects referenced from this stack frame -
- * both Java and JNI local objects
- *
- * @return int[] and array containing the object Ids. If there are no local
- * objects to the frame, and empty array will be returned
- */
- public int[] getLocalObjectsIds();
-
- /**
- * Get the text representation of the stack frame
- *
- * @return java.lang.String the text representation of the stack fame - class and method
- */
- public String getText();
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/IThreadStack.java b/src/main/java/org/eclipse/mat/snapshot/model/IThreadStack.java
deleted file mode 100644
index 4de7710..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/IThreadStack.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-/**
- * May be subject of change
- *
- * @noimplement
- * @since 0.8
- */
-public interface IThreadStack {
-
- /**
- * Get the stack frames (i.e. the different method calls) of the thread
- * stack
- *
- * @return {@link IStackFrame}[] an array containing all stack frames. The
- * first element of the array contains the top of the stack, and the
- * last element the bottom of the stack
- */
- public IStackFrame[] getStackFrames();
-
- /**
- * Get the ID of the thread to which this stack belongs
- *
- * @return the object ID of the thread owning this stack
- */
- public int getThreadId();
-}
\ No newline at end of file
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/NamedReference.java b/src/main/java/org/eclipse/mat/snapshot/model/NamedReference.java
deleted file mode 100644
index 3f0c081..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/NamedReference.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-import org.eclipse.mat.snapshot.ISnapshot;
-
-/**
- * A named reference.
- */
-public class NamedReference extends ObjectReference {
- private static final long serialVersionUID = 1L;
-
- private String name;
-
- public NamedReference(ISnapshot snapshot, long address, String name) {
- super(snapshot, address);
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/ObjectReference.java b/src/main/java/org/eclipse/mat/snapshot/model/ObjectReference.java
deleted file mode 100644
index ca9723e..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/ObjectReference.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-import java.io.Serializable;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.snapshot.ISnapshot;
-
-/**
- * The value of a field if it is an object reference.
- */
-public class ObjectReference implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private transient ISnapshot snapshot;
- private long address;
-
- public ObjectReference(ISnapshot snapshot, long address) {
- this.snapshot = snapshot;
- this.address = address;
- }
-
- public long getObjectAddress() {
- return address;
- }
-
- public int getObjectId() throws SnapshotException {
- return snapshot.mapAddressToId(address);
- }
-
- public IObject getObject() throws SnapshotException {
- return snapshot.getObject(getObjectId());
- }
-
- public String toString() {
- return "0x" + Long.toHexString(address); //$NON-NLS-1$
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/PrettyPrinter.java b/src/main/java/org/eclipse/mat/snapshot/model/PrettyPrinter.java
deleted file mode 100644
index 776cb88..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/PrettyPrinter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-import org.eclipse.mat.SnapshotException;
-
-/**
- * Utility class to extract String representations of heap dump objects.
- */
-public final class PrettyPrinter {
- /**
- * Convert a <code>java.lang.String</code> object into a String.
- */
- public static String objectAsString(IObject stringObject, int limit) throws SnapshotException {
- Integer count = (Integer) stringObject.resolveValue("count"); //$NON-NLS-1$
- if (count == null) return null;
- if (count.intValue() == 0) return ""; //$NON-NLS-1$
-
- IPrimitiveArray charArray = (IPrimitiveArray) stringObject.resolveValue("value"); //$NON-NLS-1$
- if (charArray == null) return null;
-
- Integer offset = (Integer) stringObject.resolveValue("offset"); //$NON-NLS-1$
- if (offset == null) return null;
-
- return arrayAsString(charArray, offset, count, limit);
- }
-
- /**
- * Convert a <code>char[]</code> object into a String.
- */
- public static String arrayAsString(IPrimitiveArray charArray, int offset, int count, int limit) {
- if (charArray.getType() != IObject.Type.CHAR) return null;
-
- int length = charArray.getLength();
-
- int contentToRead = count <= limit ? count : limit;
- if (contentToRead > length - offset) contentToRead = length - offset;
-
- char[] value;
- if (offset == 0 && length == contentToRead) {
- value = (char[]) charArray.getValueArray();
- } else {
- value = (char[]) charArray.getValueArray(offset, contentToRead);
- }
-
- if (value == null) return null;
-
- StringBuilder result = new StringBuilder(value.length);
- for (int ii = 0; ii < value.length; ii++) {
- char val = value[ii];
- if (val >= 32 && val < 127) {
- result.append(val);
- } else {
- result.append("\\u").append(String.format("%04x", 0xFFFF & val)); //$NON-NLS-1$//$NON-NLS-2$
- }
- }
- if (limit < count) result.append("..."); //$NON-NLS-1$
- return result.toString();
- }
-
- private PrettyPrinter() {
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/PseudoReference.java b/src/main/java/org/eclipse/mat/snapshot/model/PseudoReference.java
deleted file mode 100644
index 6c340a6..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/PseudoReference.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-import org.eclipse.mat.snapshot.ISnapshot;
-
-/**
- * Value of a field if it is a pseudo references. Some references do not
- * actually exist in the heap dump but are automatically generated because they
- * are maintained by the JVM. Examples are the link from an instance to the
- * class and from the class to the class loader.
- */
-public class PseudoReference extends NamedReference {
- private static final long serialVersionUID = 1L;
-
- public PseudoReference(ISnapshot snapshot, long address, String name) {
- super(snapshot, address, name);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/model/ThreadToLocalReference.java b/src/main/java/org/eclipse/mat/snapshot/model/ThreadToLocalReference.java
deleted file mode 100644
index 41039f2..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/model/ThreadToLocalReference.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.model;
-
-import org.eclipse.mat.snapshot.ISnapshot;
-
-/**
- * The class represents a references from a running thread object to objects
- * which are local for this thread. Such objects could be for example java local
- * variables, objects used for synchronization in this thread, etc...
- */
-public class ThreadToLocalReference extends PseudoReference {
- private static final long serialVersionUID = 1L;
- private int localObjectId;
- private GCRootInfo[] gcRootInfo;
-
- public ThreadToLocalReference(ISnapshot snapshot, long address, String name, int localObjectId,
- GCRootInfo[] gcRootInfo) {
- super(snapshot, address, name);
- this.localObjectId = localObjectId;
- this.gcRootInfo = gcRootInfo;
- }
-
- public int getObjectId() {
- return localObjectId;
- }
-
- public GCRootInfo[] getGcRootInfo() {
- return gcRootInfo;
- }
-}
diff --git a/src/main/java/org/eclipse/mat/snapshot/registry/ClassSpecificNameResolverRegistry.java b/src/main/java/org/eclipse/mat/snapshot/registry/ClassSpecificNameResolverRegistry.java
deleted file mode 100644
index 59be1ea..0000000
--- a/src/main/java/org/eclipse/mat/snapshot/registry/ClassSpecificNameResolverRegistry.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.snapshot.registry;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.eclipse.mat.SnapshotException;
-import org.eclipse.mat.hprof.Messages;
-import org.eclipse.mat.snapshot.extension.IClassSpecificNameResolver;
-import org.eclipse.mat.snapshot.extension.Subject;
-import org.eclipse.mat.snapshot.extension.Subjects;
-import org.eclipse.mat.snapshot.model.IClass;
-import org.eclipse.mat.snapshot.model.IObject;
-import org.eclipse.mat.util.MessageUtil;
-
-/**
- * Registry for name resolvers which resolve the names for objects of specific
- * classes (found in an snapshot), e.g. String (where the char[] is evaluated)
- * or a specific class loader (where the appropriate field holding its name and
- * thereby deployment unit is evaluated).
- */
-public final class ClassSpecificNameResolverRegistry {
- // //////////////////////////////////////////////////////////////
- // Singleton
- // //////////////////////////////////////////////////////////////
-
- /** inner class because RegitryReader API not public */
- private static class RegistryImpl {
- private Map<String, IClassSpecificNameResolver> resolvers;
-
- public RegistryImpl() {
- resolvers = new HashMap<String, IClassSpecificNameResolver>();
- }
-
- private String doResolve(IObject object) {
- try {
- IClass clazz = object.getClazz();
- while (clazz != null) {
- IClassSpecificNameResolver resolver = resolvers.get(clazz.getName());
- if (resolver != null) {
- return resolver.resolve(object);
- }
- clazz = clazz.getSuperClass();
- }
- return null;
- } catch (RuntimeException e) {
- Logger.getLogger(ClassSpecificNameResolverRegistry.class.getName())
- .log(Level.SEVERE, MessageUtil.format(
- Messages.ClassSpecificNameResolverRegistry_ErrorMsg_DuringResolving,
- object.getTechnicalName()), e);
- return null;
- } catch (SnapshotException e) {
- Logger.getLogger(ClassSpecificNameResolverRegistry.class.getName())
- .log(Level.SEVERE, MessageUtil.format(
- Messages.ClassSpecificNameResolverRegistry_ErrorMsg_DuringResolving,
- object.getTechnicalName()), e);
- return null;
- }
- }
-
- public void registerResolver(IClassSpecificNameResolver resolver) {
- String[] subjects = extractSubjects(resolver);
- if (subjects != null && subjects.length > 0) {
- for (int ii = 0; ii < subjects.length; ii++)
- instance().registry.resolvers.put(subjects[ii], resolver);
- }
- }
-
- private String[] extractSubjects(IClassSpecificNameResolver instance) {
- Subjects subjects = instance.getClass().getAnnotation(Subjects.class);
- if (subjects != null) return subjects.value();
-
- Subject subject = instance.getClass().getAnnotation(Subject.class);
- return subject != null ? new String[] { subject.value() } : null;
- }
- }
-
- private static ClassSpecificNameResolverRegistry instance =
- new ClassSpecificNameResolverRegistry();
-
- static {
- instance.registry.registerResolver(
- new org.eclipse.mat.inspections.CommonNameResolver.StringResolver());
- instance.registry.registerResolver(
- new org.eclipse.mat.inspections.CommonNameResolver.StringBufferResolver());
- instance.registry.registerResolver(
- new org.eclipse.mat.inspections.CommonNameResolver.ThreadResolver());
- instance.registry.registerResolver(
- new org.eclipse.mat.inspections.CommonNameResolver.ThreadGroupResolver());
- instance.registry.registerResolver(
- new org.eclipse.mat.inspections.CommonNameResolver.ValueResolver());
- instance.registry.registerResolver(
- new org.eclipse.mat.inspections.CommonNameResolver.CharArrayResolver());
- instance.registry.registerResolver(
- new org.eclipse.mat.inspections.CommonNameResolver.ByteArrayResolver());
- instance.registry.registerResolver(
- new org.eclipse.mat.inspections.CommonNameResolver.URLResolver());
- instance.registry.registerResolver(
- new org.eclipse.mat.inspections.CommonNameResolver.AccessibleObjectResolver());
- instance.registry.registerResolver(
- new org.eclipse.mat.inspections.CommonNameResolver.FieldResolver());
- instance.registry.registerResolver(
- new org.eclipse.mat.inspections.CommonNameResolver.MethodResolver());
- instance.registry.registerResolver(
- new org.eclipse.mat.inspections.CommonNameResolver.ConstructorResolver());
- // instance.registry.registerResolver(new org.eclipse.mat.inspections.eclipse.EclipseNameResolver.EclipseClassLoaderResolver());
- // instance.registry.registerResolver(new org.eclipse.mat.inspections.eclipse.EclipseNameResolver.EclipseDefaultClassLoaderResolver());
- // instance.registry.registerResolver(new org.eclipse.mat.inspections.eclipse.EclipseNameResolver.StartupClassLoaderResolver());
- // instance.registry.registerResolver(new org.eclipse.mat.inspections.eclipse.EclipseNameResolver.RGBResolver());
- // instance.registry.registerResolver(new org.eclipse.mat.inspections.eclipse.EclipseNameResolver.PointResolver());
- // instance.registry.registerResolver(new org.eclipse.mat.inspections.eclipse.EclipseNameResolver.RectangleResolver());
- // instance.registry.registerResolver(new org.eclipse.mat.inspections.jetty.JettyNameResolvers.WebAppClassLoaderResolver());
- // instance.registry.registerResolver(new org.eclipse.mat.inspections.jetty.JettyNameResolvers.JasperLoaderResolver());
- }
-
- public static ClassSpecificNameResolverRegistry instance() {
- return instance;
- }
-
- // //////////////////////////////////////////////////////////////
- // registry methods
- // //////////////////////////////////////////////////////////////
-
- private RegistryImpl registry;
-
- private ClassSpecificNameResolverRegistry() {
- registry = new RegistryImpl();
- }
-
- /**
- * Resolve name of the given snapshot object or return null if it can't be
- * resolved.
- *
- * @param object snapshot object for which the name should be resolved
- * @return name of the given snapshot object or null if it can't be resolved
- */
- public static String resolve(IObject object) {
- if (object == null) {
- throw new NullPointerException(
- Messages.ClassSpecificNameResolverRegistry_Error_MissingObject.pattern);
- }
-
- return instance().registry.doResolve(object);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/util/IProgressListener.java b/src/main/java/org/eclipse/mat/util/IProgressListener.java
deleted file mode 100644
index a09b171..0000000
--- a/src/main/java/org/eclipse/mat/util/IProgressListener.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.util;
-
-import org.eclipse.mat.hprof.Messages;
-
-/**
- * This interface is closely modeled after
- * {@link org.eclipse.core.runtime.IProgressMonitor}. The latter has not been
- * used to avoid a dependency. It is implemented by objects that monitor the
- * progress of an activity; the methods in this interface are invoked by code
- * that performs the activity.
- * <p>
- * All activity is broken down into a linear sequence of tasks against which
- * progress is reported. When a task begins, a <code>beginTask(String, int)
- * </code> notification is reported,
- * followed by any number and mixture of progress reports (<code>worked()</code>
- * ) and subtask notifications (<code>subTask(String)</code>). When the task is
- * eventually completed, a <code>done()</code> notification is reported. After
- * the <code>done()</code> notification, the progress monitor cannot be reused;
- * i.e., <code>
- * beginTask(String, int)</code> cannot be called again after the call to
- * <code>done()</code>.
- * <p>
- * A request to cancel an operation can be signaled using the
- * <code>setCanceled</code> method. Operations taking a progress monitor are
- * expected to poll the monitor (using <code>isCanceled</code>) periodically and
- * abort at their earliest convenience. Operation can however choose to ignore
- * cancellation requests.
- * <p>
- * Since notification is synchronous with the activity itself, the listener
- * should provide a fast and robust implementation. If the handling of
- * notifications would involve blocking operations, or operations which might
- * throw uncaught exceptions, the notifications should be queued, and the actual
- * processing deferred (or perhaps delegated to a separate thread).
- */
-public interface IProgressListener {
- /**
- * Helper exception class which can be used to exit an operation via an
- * exception if the operation itself has been canceled. This exception is
- * not thrown by the listener itself - this has to be done by the
- * implementation using it. It is only available here for convenience
- * reasons to get rid of the various CanceledException throughout the code.
- */
- public class OperationCanceledException extends RuntimeException {
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * Constant which may be used to indicate that the total amount of work
- * units is not known.
- */
- public final static int UNKNOWN_TOTAL_WORK = -1;
-
- /**
- * Notifies that the main task is beginning. This must only be called once
- * on a given progress monitor instance.
- *
- * @param name the name (or description) of the main task
- * @param totalWork the total number of work units into which the main task is
- * been subdivided. If the value is <code>UNKNOWN</code> the
- * implementation is free to indicate progress in a way which
- * doesn't require the total number of work units in advance.
- */
- void beginTask(String name, int totalWork);
-
- void beginTask(Messages name, int totalWork);
-
- /**
- * Notifies that the work is done; that is, either the main task is
- * completed or the user canceled it. This method may be called more than
- * once (implementations should be prepared to handle this case).
- */
- public void done();
-
- /**
- * Returns whether cancelation of current operation has been requested.
- * Long-running operations should poll to see if cancelation has been
- * requested.
- *
- * @return <code>true</code> if cancellation has been requested, and
- * <code>false</code> otherwise
- * @see #setCanceled(boolean)
- */
- public boolean isCanceled();
-
- /**
- * Sets the cancel state to the given value.
- *
- * @param value <code>true</code> indicates that cancelation has been
- * requested (but not necessarily acknowledged);
- * <code>false</code> clears this flag
- * @see #isCanceled()
- */
- public void setCanceled(boolean value);
-
- /**
- * Notifies that a subtask of the main task is beginning. Subtasks are
- * optional; the main task might not have subtasks.
- *
- * @param name the name (or description) of the subtask
- */
- public void subTask(String name);
-
- /**
- * Notifies that a given number of work unit of the main task has been
- * completed. Note that this amount represents an installment, as opposed to
- * a cumulative amount of work done to date.
- *
- * @param work the number of work units just completed
- */
- public void worked(int work);
-
- /**
- * Defines the severites possible for a user message.
- * <ul>
- * <li><code>ERROR</code> - a serious error (most severe)</li> <li><code>
- * WARNING</code> - a warning (less severe)</li> <li><code>INFO</code> - an
- * informational ("fyi") message (least severe)</li>
- * </ul>
- * <p>
- */
- public enum Severity {
- /** Severity indicating this user message is informational only. */
- INFO,
- /** Severity indicating this user message represents a warning. */
- WARNING,
- /** Severity indicating this user message represents an error. */
- ERROR
- }
-
- /**
- * Sends a message to the user.
- *
- * @param severity Severity as defined in {@link Severity}
- * @param message The message localized to the current locale.
- * @param exception The relevant low-level exception, or <code>null</code> if
- * none.
- */
- public void sendUserMessage(Severity severity, String message, Throwable exception);
-}
diff --git a/src/main/java/org/eclipse/mat/util/MessageUtil.java b/src/main/java/org/eclipse/mat/util/MessageUtil.java
deleted file mode 100644
index 4215890..0000000
--- a/src/main/java/org/eclipse/mat/util/MessageUtil.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.eclipse.mat.util;
-
-import java.text.MessageFormat;
-import org.eclipse.mat.hprof.Messages;
-
-public final class MessageUtil {
-
- public static String format(Messages message, Object... objects) {
- if (objects.length == 0) {
- return message.pattern;
- }
- return MessageFormat.format(message.pattern, objects);
- }
-
- private MessageUtil() {
- throw new AssertionError();
- }
-}
diff --git a/src/main/java/org/eclipse/mat/util/SilentProgressListener.java b/src/main/java/org/eclipse/mat/util/SilentProgressListener.java
deleted file mode 100644
index 8bd7b8c..0000000
--- a/src/main/java/org/eclipse/mat/util/SilentProgressListener.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2009 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.util;
-
-import org.eclipse.mat.hprof.Messages;
-
-/**
- * @since 0.8
- */
-public class SilentProgressListener implements IProgressListener {
- IProgressListener delegate;
-
- public SilentProgressListener(IProgressListener delegate) {
- this.delegate = delegate;
- }
-
- public void beginTask(String name, int totalWork) {
- }
-
- public final void beginTask(Messages name, int totalWork) {
- beginTask(name.pattern, totalWork);
- }
-
- public void done() {
- }
-
- public boolean isCanceled() {
- return delegate.isCanceled();
- }
-
- public void sendUserMessage(Severity severity, String message, Throwable exception) {
- delegate.sendUserMessage(severity, message, exception);
- }
-
- public void setCanceled(boolean value) {
- delegate.setCanceled(value);
- }
-
- public void subTask(String name) {
- }
-
- public void worked(int work) {
- }
-}
diff --git a/src/main/java/org/eclipse/mat/util/SimpleMonitor.java b/src/main/java/org/eclipse/mat/util/SimpleMonitor.java
deleted file mode 100644
index 281aef3..0000000
--- a/src/main/java/org/eclipse/mat/util/SimpleMonitor.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.util;
-
-import org.eclipse.mat.hprof.Messages;
-
-public class SimpleMonitor {
- String task;
- IProgressListener delegate;
- int currentMonitor;
- int[] percentages;
-
- public SimpleMonitor(String task, IProgressListener monitor, int[] percentages) {
- this.task = task;
- this.delegate = monitor;
- this.percentages = percentages;
- }
-
- public IProgressListener nextMonitor() {
- if (currentMonitor == 0) {
- int total = 0;
- for (int ii : percentages)
- total += ii;
- delegate.beginTask(task, total);
- }
-
- return new Listener(percentages[currentMonitor++]);
- }
-
- public class Listener implements IProgressListener {
- long counter;
-
- int majorUnits;
- int unitsReported;
- long workDone;
- long workPerUnit;
-
- boolean isSmaller;
-
- public Listener(int majorUnits) {
- this.majorUnits = majorUnits;
- }
-
- public final void beginTask(Messages name, int totalWork) {
- beginTask(name.pattern, totalWork);
- }
-
- public void beginTask(String name, int totalWork) {
- if (name != null) delegate.subTask(name);
-
- if (totalWork == 0) return;
-
- isSmaller = totalWork < majorUnits;
- workPerUnit = isSmaller ? majorUnits / totalWork : totalWork / majorUnits;
- unitsReported = 0;
- }
-
- public void subTask(String name) {
- delegate.subTask(name);
- }
-
- public void done() {
- if (majorUnits - unitsReported > 0) delegate.worked(majorUnits - unitsReported);
- }
-
- public boolean isCanceled() {
- return delegate.isCanceled();
- }
-
- public boolean isProbablyCanceled() {
- return counter++ % 5000 == 0 ? isCanceled() : false;
- }
-
- public void totalWorkDone(long work) {
- if (workDone == work) return;
-
- if (workPerUnit == 0) return;
-
- workDone = work;
- int unitsWorked = isSmaller ? (int) (work * workPerUnit) : (int) (work / workPerUnit);
- int unitsToReport = unitsWorked - unitsReported;
-
- if (unitsToReport > 0) {
- delegate.worked(unitsToReport);
- unitsReported += unitsToReport;
- }
- }
-
- public void worked(int work) {
- totalWorkDone(workDone + work);
- }
-
- public void setCanceled(boolean value) {
- delegate.setCanceled(value);
- }
-
- public void sendUserMessage(Severity severity, String message, Throwable exception) {
- delegate.sendUserMessage(severity, message, exception);
- }
-
- public long getWorkDone() {
- return workDone;
- }
- }
-}
diff --git a/src/main/java/org/eclipse/mat/util/SimpleStringTokenizer.java b/src/main/java/org/eclipse/mat/util/SimpleStringTokenizer.java
deleted file mode 100644
index 4482ffe..0000000
--- a/src/main/java/org/eclipse/mat/util/SimpleStringTokenizer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-public final class SimpleStringTokenizer implements Iterable<String> {
- private String subject;
- private char delim;
-
- public SimpleStringTokenizer(String subject, char delim) {
- this.subject = subject;
- this.delim = delim;
- }
-
- public Iterator<String> iterator() {
- return new Iterator<String>() {
- int position = 0;
- int maxPosition = subject.length();
-
- public boolean hasNext() {
- return position < maxPosition;
- }
-
- public String next() {
- if (position >= maxPosition) throw new NoSuchElementException();
-
- String answer;
-
- int p = subject.indexOf(delim, position);
-
- if (p < 0) {
- answer = subject.substring(position);
- position = maxPosition;
- return answer;
- } else {
- answer = subject.substring(position, p);
- position = p + 1;
- }
-
- return answer;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- public static String[] split(String subject, char delim) {
- List<String> answer = new ArrayList<String>();
- for (String s : new SimpleStringTokenizer(subject, delim))
- answer.add(s.trim());
- return answer.toArray(new String[0]);
- }
-}
diff --git a/src/main/java/org/eclipse/mat/util/VoidProgressListener.java b/src/main/java/org/eclipse/mat/util/VoidProgressListener.java
deleted file mode 100644
index c1c4771..0000000
--- a/src/main/java/org/eclipse/mat/util/VoidProgressListener.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * ****************************************************************************
- * Copyright (c) 2008 SAP AG.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * SAP AG - initial API and implementation
- * *****************************************************************************
- */
-package org.eclipse.mat.util;
-
-import org.eclipse.mat.hprof.Messages;
-
-/**
- * Empty implementation of {@link IProgressListener} which is frequently used
- * throughout the snapshot API in ISnapshot to get feedback for long running
- * operations. This implementation does nothing.
- *
- * @see IProgressListener
- */
-public class VoidProgressListener implements IProgressListener {
- private boolean cancelled = false;
-
- /**
- * Does nothing.
- *
- * @see IProgressListener#beginTask(String, int)
- */
- public void beginTask(String name, int totalWork) {
- }
-
- public final void beginTask(Messages name, int totalWork) {
- beginTask(name.pattern, totalWork);
- }
-
- /**
- * Does nothing.
- *
- * @see IProgressListener#done()
- */
- public void done() {
- }
-
- /**
- * Gets the cancel state.
- *
- * @see IProgressListener#isCanceled()
- */
- public boolean isCanceled() {
- return cancelled;
- }
-
- /**
- * Sets the cancel state.
- *
- * @see IProgressListener#setCanceled(boolean)
- */
- public void setCanceled(boolean value) {
- cancelled = value;
- }
-
- /**
- * Does nothing.
- *
- * @see IProgressListener#subTask(String)
- */
- public void subTask(String name) {
- }
-
- /**
- * Does nothing.
- *
- * @see IProgressListener#worked(int)
- */
- public void worked(int work) {
- }
-
- /**
- * Does nothing
- *
- * @see IProgressListener#sendUserMessage(Severity, String, Throwable)
- */
- public void sendUserMessage(Severity severity, String message, Throwable exception) {
- }
-}
diff --git a/trove/NOTICE b/trove/NOTICE
new file mode 100644
index 0000000..950088a
--- /dev/null
+++ b/trove/NOTICE
@@ -0,0 +1,511 @@
+The source code for GNU Trove is licensed under the Lesser GNU Public License (LGPL).
+
+This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Two classes (HashFunctions and PrimeFinder) included in Trove are licensed under the following terms:
+Copyright (c) 1999 CERN - European Organization for Nuclear Research. Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. CERN makes no representations about the suitability of this software for any purpose. It is provided "as is" without expressed or implied warranty.
+
+
+
+GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
\ No newline at end of file
diff --git a/trove/PREBUILT b/trove/PREBUILT
new file mode 100644
index 0000000..ac7cc8c
--- /dev/null
+++ b/trove/PREBUILT
@@ -0,0 +1,12 @@
+Trove: High Performance Collections for Java
+http://http://trove.starlight-systems.com/
+
+Imported trove4j "1.1 (with patches from JetBrains)" that Android Studio uses:
+
+$ mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file \
+ -Dfile=tools/idea/lib/trove4j.jar \
+ -Dsources=tools/idea/lib/src/trove4j_src.jar \
+ -DgroupId=net.sf.trove4j \
+ -DartifactId=trove4j -Dversion=1.1 -Dpackaging=jar -DgeneratePom=true \
+ -DlocalRepositoryPath=prebuilts/tools/common/m2/repository \
+ -DcreateChecksum=true
diff --git a/trove/README.md b/trove/README.md
new file mode 100644
index 0000000..b0c270b
--- /dev/null
+++ b/trove/README.md
@@ -0,0 +1,11 @@
+Trove: High Performance Collections for Java
+http://trove.starlight-systems.com/
+
+perflib and Android Studio use trove4j "1.1 (with patches from JetBrains)" which isn't available on Maven Central.
+
+The `trove4j-1.1-sources.jar-unzipped_flattened` directory was created the following way:
+
+* Check out the Android platform/prebuilts/tools repository at commit 3fde540f482afc68b847f8e85672acc145606ffe
+* `common/m2/repository/net/sf/trove4j/trove4j/1.1` contains `trove4j-1.1-sources.jar`
+* Unzip `trove4j-1.1-sources.jar`
+* Merge `core/src/gnu/trove` and `generated/src/gnu/trove` in one source folder.
\ No newline at end of file
diff --git a/trove/m2_repo b/trove/m2_repo
new file mode 120000
index 0000000..694a6c8
--- /dev/null
+++ b/trove/m2_repo
@@ -0,0 +1 @@
+../android_platform_prebuilts_tools/common/m2/repository/net/sf/trove4j/trove4j/1.1
\ No newline at end of file
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/CanonicalEquality.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/CanonicalEquality.java
new file mode 100755
index 0000000..f6c7ac3
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/CanonicalEquality.java
@@ -0,0 +1,9 @@
+package gnu.trove;
+
+
+class CanonicalEquality<T> implements Equality<T> {
+ @Override
+ public boolean equals(T o1, T o2) {
+ return o1 != null ? o1.equals(o2) : o2 == null;
+ }
+}
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/Equality.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/Equality.java
new file mode 100755
index 0000000..70448f4
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/Equality.java
@@ -0,0 +1,7 @@
+package gnu.trove;
+
+public interface Equality<T> {
+ Equality CANONICAL = new CanonicalEquality();
+ Equality IDENTITY = new IdentityEquality();
+ boolean equals(T o1, T o2);
+}
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/HashFunctions.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/HashFunctions.java
new file mode 100755
index 0000000..18c454f
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/HashFunctions.java
@@ -0,0 +1,107 @@
+// Copyright (c) 1999 CERN - European Organization for Nuclear Research.
+
+// Permission to use, copy, modify, distribute and sell this software and
+// its documentation for any purpose is hereby granted without fee,
+// provided that the above copyright notice appear in all copies and that
+// both that copyright notice and this permission notice appear in
+// supporting documentation. CERN makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
+// without expressed or implied warranty.
+
+package gnu.trove;
+
+/**
+ * Provides various hash functions.
+ *
+ * @author wolfgang.hoschek@cern.ch
+ * @version 1.0, 09/24/99
+ */
+public final class HashFunctions {
+ /**
+ * Returns a hashcode for the specified value.
+ *
+ * @return a hash code value for the specified value.
+ */
+ public static int hash(double value) {
+ long bits = Double.doubleToLongBits(value);
+ return (int)(bits ^ (bits >>> 32));
+ //return (int) Double.doubleToLongBits(value*663608941.737);
+ //this avoids excessive hashCollisions in the case values are
+ //of the form (1.0, 2.0, 3.0, ...)
+ }
+
+ /**
+ * Returns a hashcode for the specified value.
+ *
+ * @return a hash code value for the specified value.
+ */
+ public static int hash(float value) {
+ return Float.floatToIntBits(value*663608941.737f);
+ // this avoids excessive hashCollisions in the case values are
+ // of the form (1.0, 2.0, 3.0, ...)
+ }
+
+ /**
+ * Returns a hashcode for the specified value. The hashcode is computed as
+ * <blockquote><pre>
+ * 31^5*(d[0]*31^(n-1) + d[1]*31^(n-2) + ... + d[n-1])
+ * </pre></blockquote>
+ * using <code>int</code> arithmetic, where <code>d[i]</code> is
+ * the <i>i</i>th digit of the value, counting from the right,
+ * <code>n</code> is the number of decimal digits of the specified
+ * value, and <code>^</code> indicates exponentiation. (The hash
+ * value of the value zero is zero.)
+ *
+ * @return a hash code value for the specified value.
+ */
+ public static int hash(int value) {
+ //return value * 0x278DDE6D; // see cern.jet.random.engine.DRand
+
+ return value;
+
+ /*
+ value &= 0x7FFFFFFF; // make it >=0
+ int hashCode = 0;
+ do hashCode = 31*hashCode + value%10;
+ while ((value /= 10) > 0);
+
+ return 28629151*hashCode; // spread even further; h*31^5
+ */
+ }
+
+ /**
+ * Returns a hashcode for the specified value.
+ *
+ * @return a hash code value for the specified value.
+ */
+ public static int hash(long value) {
+ return (int)(value ^ (value >> 32));
+
+ /*
+ * The hashcode is computed as
+ * <blockquote><pre>
+ * 31^5*(d[0]*31^(n-1) + d[1]*31^(n-2) + ... + d[n-1])
+ * </pre></blockquote>
+ * using <code>int</code> arithmetic, where <code>d[i]</code> is the
+ * <i>i</i>th digit of the value, counting from the right, <code>n</code> is the number of decimal digits of the specified value,
+ * and <code>^</code> indicates exponentiation.
+ * (The hash value of the value zero is zero.)
+
+ value &= 0x7FFFFFFFFFFFFFFFL; // make it >=0 (0x7FFFFFFFFFFFFFFFL==Long.MAX_VALUE)
+ int hashCode = 0;
+ do hashCode = 31*hashCode + (int) (value%10);
+ while ((value /= 10) > 0);
+
+ return 28629151*hashCode; // spread even further; h*31^5
+ */
+ }
+
+ /**
+ * Returns a hashcode for the specified object.
+ *
+ * @return a hash code value for the specified object.
+ */
+ public static int hash(Object object) {
+ return object==null ? 0 : object.hashCode();
+ }
+}
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/IdentityEquality.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/IdentityEquality.java
new file mode 100755
index 0000000..22e207d
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/IdentityEquality.java
@@ -0,0 +1,8 @@
+package gnu.trove;
+
+class IdentityEquality<T> implements Equality<T> {
+ @Override
+ public boolean equals(T o1, T o2) {
+ return o1 == o2;
+ }
+}
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/PrimeFinder.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/PrimeFinder.java
new file mode 100755
index 0000000..5e787e9
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/PrimeFinder.java
@@ -0,0 +1,158 @@
+// Copyright 1999 CERN - European Organization for Nuclear Research.
+
+// Permission to use, copy, modify, distribute and sell this software
+// and its documentation for any purpose is hereby granted without fee,
+// provided that the above copyright notice appear in all copies and
+// that both that copyright notice and this permission notice appear in
+// supporting documentation. CERN makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
+// without expressed or implied warranty.
+package gnu.trove;
+
+import java.util.Arrays;
+
+/*
+ * Modified for Trove to use the java.util.Arrays sort/search
+ * algorithms instead of those provided with colt.
+ */
+
+/**
+ * Used to keep hash table capacities prime numbers.
+ * Not of interest for users; only for implementors of hashtables.
+ *
+ * <p>Choosing prime numbers as hash table capacities is a good idea
+ * to keep them working fast, particularly under hash table
+ * expansions.
+ *
+ * <p>However, JDK 1.2, JGL 3.1 and many other toolkits do nothing to
+ * keep capacities prime. This class provides efficient means to
+ * choose prime capacities.
+ *
+ * <p>Choosing a prime is <tt>O(log 300)</tt> (binary search in a list
+ * of 300 ints). Memory requirements: 1 KB static memory.
+ *
+ * @author wolfgang.hoschek@cern.ch
+ * @version 1.0, 09/24/99
+ */
+public final class PrimeFinder {
+ /**
+ * The largest prime this class can generate; currently equal to
+ * <tt>Integer.MAX_VALUE</tt>.
+ */
+ public static final int largestPrime = Integer.MAX_VALUE; //yes, it is prime.
+
+ /**
+ * The prime number list consists of 11 chunks.
+ *
+ * Each chunk contains prime numbers.
+ *
+ * A chunk starts with a prime P1. The next element is a prime
+ * P2. P2 is the smallest prime for which holds: P2 >= 2*P1.
+ *
+ * The next element is P3, for which the same holds with respect
+ * to P2, and so on.
+ *
+ * Chunks are chosen such that for any desired capacity >= 1000
+ * the list includes a prime number <= desired capacity * 1.11.
+ *
+ * Therefore, primes can be retrieved which are quite close to any
+ * desired capacity, which in turn avoids wasting memory.
+ *
+ * For example, the list includes
+ * 1039,1117,1201,1277,1361,1439,1523,1597,1759,1907,2081.
+ *
+ * So if you need a prime >= 1040, you will find a prime <=
+ * 1040*1.11=1154.
+ *
+ * Chunks are chosen such that they are optimized for a hashtable
+ * growthfactor of 2.0;
+ *
+ * If your hashtable has such a growthfactor then, after initially
+ * "rounding to a prime" upon hashtable construction, it will
+ * later expand to prime capacities such that there exist no
+ * better primes.
+ *
+ * In total these are about 32*10=320 numbers -> 1 KB of static
+ * memory needed.
+ *
+ * If you are stingy, then delete every second or fourth chunk.
+ */
+
+ private static final int[] primeCapacities = {
+ //chunk #0
+ largestPrime,
+
+ //chunk #1
+ 5,11,23,47,97,197,397,797,1597,3203,6421,12853,25717,51437,102877,205759,
+ 411527,823117,1646237,3292489,6584983,13169977,26339969,52679969,105359939,
+ 210719881,421439783,842879579,1685759167,
+
+ //chunk #2
+ 433,877,1759,3527,7057,14143,28289,56591,113189,226379,452759,905551,1811107,
+ 3622219,7244441,14488931,28977863,57955739,115911563,231823147,463646329,927292699,
+ 1854585413,
+
+ //chunk #3
+ 953,1907,3821,7643,15287,30577,61169,122347,244703,489407,978821,1957651,3915341,
+ 7830701,15661423,31322867,62645741,125291483,250582987,501165979,1002331963,
+ 2004663929,
+
+ //chunk #4
+ 1039,2081,4177,8363,16729,33461,66923,133853,267713,535481,1070981,2141977,4283963,
+ 8567929,17135863,34271747,68543509,137087021,274174111,548348231,1096696463,
+
+ //chunk #5
+ 31,67,137,277,557,1117,2237,4481,8963,17929,35863,71741,143483,286973,573953,
+ 1147921,2295859,4591721,9183457,18366923,36733847,73467739,146935499,293871013,
+ 587742049,1175484103,
+
+ //chunk #6
+ 599,1201,2411,4831,9677,19373,38747,77509,155027,310081,620171,1240361,2480729,
+ 4961459,9922933,19845871,39691759,79383533,158767069,317534141,635068283,1270136683,
+
+ //chunk #7
+ 311,631,1277,2557,5119,10243,20507,41017,82037,164089,328213,656429,1312867,
+ 2625761,5251529,10503061,21006137,42012281,84024581,168049163,336098327,672196673,
+ 1344393353,
+
+ //chunk #8
+ 3,7,17,37,79,163,331,673,1361,2729,5471,10949,21911,43853,87719,175447,350899,
+ 701819,1403641,2807303,5614657,11229331,22458671,44917381,89834777,179669557,
+ 359339171,718678369,1437356741,
+
+ //chunk #9
+ 43,89,179,359,719,1439,2879,5779,11579,23159,46327,92657,185323,370661,741337,
+ 1482707,2965421,5930887,11861791,23723597,47447201,94894427,189788857,379577741,
+ 759155483,1518310967,
+
+ //chunk #10
+ 379,761,1523,3049,6101,12203,24407,48817,97649,195311,390647,781301,1562611,
+ 3125257,6250537,12501169,25002389,50004791,100009607,200019221,400038451,800076929,
+ 1600153859
+ };
+
+ static { //initializer
+ // The above prime numbers are formatted for human readability.
+ // To find numbers fast, we sort them once and for all.
+
+ Arrays.sort(primeCapacities);
+ }
+
+ /**
+ * Returns a prime number which is <code>>= desiredCapacity</code>
+ * and very close to <code>desiredCapacity</code> (within 11% if
+ * <code>desiredCapacity >= 1000</code>).
+ *
+ * @param desiredCapacity the capacity desired by the user.
+ * @return the capacity which should be used for a hashtable.
+ */
+ public static int nextPrime(int desiredCapacity) {
+ int i = Arrays.binarySearch(primeCapacities, desiredCapacity);
+ if (i<0) {
+ // desired capacity not found, choose next prime greater
+ // than desired capacity
+ i = -i -1; // remember the semantics of binarySearch...
+ }
+ return primeCapacities[i];
+ }
+}
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/SerializationProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/SerializationProcedure.java
new file mode 100755
index 0000000..a391a59
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/SerializationProcedure.java
@@ -0,0 +1,433 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+/**
+ * Implementation of the variously typed procedure interfaces that supports
+ * writing the arguments to the procedure out on an ObjectOutputStream.
+ * In the case of two-argument procedures, the arguments are written out
+ * in the order received.
+ *
+ * <p>
+ * Any IOException is trapped here so that it can be rethrown in a writeObject
+ * method.
+ * </p>
+ *
+ * Created: Sun Jul 7 00:14:18 2002
+ *
+ * @author Eric D. Friedman
+ * @version $Id: SerializationProcedure.java,v 1.6 2004/09/24 09:11:15 cdr Exp $
+ */
+
+class SerializationProcedure implements TDoubleDoubleProcedure,
+ TDoubleFloatProcedure,
+ TDoubleIntProcedure,
+ TDoubleLongProcedure,
+ TDoubleObjectProcedure,
+ TDoubleProcedure,
+ TFloatDoubleProcedure,
+ TFloatFloatProcedure,
+ TFloatIntProcedure,
+ TFloatLongProcedure,
+ TFloatObjectProcedure,
+ TFloatProcedure,
+ TIntDoubleProcedure,
+ TIntFloatProcedure,
+ TIntIntProcedure,
+ TIntLongProcedure,
+ TIntObjectProcedure,
+ TIntProcedure,
+ TLongDoubleProcedure,
+ TLongFloatProcedure,
+ TLongIntProcedure,
+ TLongLongProcedure,
+ TLongObjectProcedure,
+ TLongProcedure,
+ TObjectDoubleProcedure,
+ TObjectFloatProcedure,
+ TObjectIntProcedure,
+ TObjectLongProcedure,
+ TObjectObjectProcedure,
+ TObjectProcedure {
+
+ private final ObjectOutputStream stream;
+ IOException exception;
+
+ SerializationProcedure (ObjectOutputStream stream) {
+ this.stream = stream;
+ }
+
+ @Override
+ public boolean execute(int val) {
+ try {
+ stream.writeInt(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(double val) {
+ try {
+ stream.writeDouble(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(long val) {
+ try {
+ stream.writeLong(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(float val) {
+ try {
+ stream.writeFloat(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(Object val) {
+ try {
+ stream.writeObject(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(Object key, Object val) {
+ try {
+ stream.writeObject(key);
+ stream.writeObject(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(Object key, int val) {
+ try {
+ stream.writeObject(key);
+ stream.writeInt(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(Object key, long val) {
+ try {
+ stream.writeObject(key);
+ stream.writeLong(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(Object key, double val) {
+ try {
+ stream.writeObject(key);
+ stream.writeDouble(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(Object key, float val) {
+ try {
+ stream.writeObject(key);
+ stream.writeFloat(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(int key, Object val) {
+ try {
+ stream.writeInt(key);
+ stream.writeObject(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(int key, int val) {
+ try {
+ stream.writeInt(key);
+ stream.writeInt(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(int key, long val) {
+ try {
+ stream.writeInt(key);
+ stream.writeLong(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(int key, double val) {
+ try {
+ stream.writeInt(key);
+ stream.writeDouble(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(int key, float val) {
+ try {
+ stream.writeInt(key);
+ stream.writeFloat(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(long key, Object val) {
+ try {
+ stream.writeLong(key);
+ stream.writeObject(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(long key, int val) {
+ try {
+ stream.writeLong(key);
+ stream.writeInt(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(long key, long val) {
+ try {
+ stream.writeLong(key);
+ stream.writeLong(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(long key, double val) {
+ try {
+ stream.writeLong(key);
+ stream.writeDouble(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(long key, float val) {
+ try {
+ stream.writeLong(key);
+ stream.writeFloat(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(double key, Object val) {
+ try {
+ stream.writeDouble(key);
+ stream.writeObject(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(double key, int val) {
+ try {
+ stream.writeDouble(key);
+ stream.writeInt(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(double key, long val) {
+ try {
+ stream.writeDouble(key);
+ stream.writeLong(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(double key, double val) {
+ try {
+ stream.writeDouble(key);
+ stream.writeDouble(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(double key, float val) {
+ try {
+ stream.writeDouble(key);
+ stream.writeFloat(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(float key, Object val) {
+ try {
+ stream.writeFloat(key);
+ stream.writeObject(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(float key, int val) {
+ try {
+ stream.writeFloat(key);
+ stream.writeInt(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(float key, long val) {
+ try {
+ stream.writeFloat(key);
+ stream.writeLong(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(float key, double val) {
+ try {
+ stream.writeFloat(key);
+ stream.writeDouble(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean execute(float key, float val) {
+ try {
+ stream.writeFloat(key);
+ stream.writeFloat(val);
+ } catch (IOException e) {
+ exception = e;
+ return false;
+ }
+ return true;
+ }
+}// SerializationProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleArrayList.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleArrayList.java
new file mode 100755
index 0000000..3e8692c
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleArrayList.java
@@ -0,0 +1,889 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Random;
+
+/**
+ * A resizable, array-backed list of double primitives.
+ *
+ * Created: Sat Dec 29 14:21:12 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TDoubleArrayList implements Serializable, Cloneable {
+
+ /** the data of the list */
+ protected transient double[] _data;
+
+ /** the index after the last entry in the list */
+ protected transient int _pos;
+
+ /** the default capacity for new lists */
+ protected static final int DEFAULT_CAPACITY = 4;
+
+ /**
+ * Creates a new <code>TDoubleArrayList</code> instance with the
+ * default capacity.
+ */
+ public TDoubleArrayList() {
+ this(DEFAULT_CAPACITY);
+ }
+
+ /**
+ * Creates a new <code>TDoubleArrayList</code> instance with the
+ * specified capacity.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ public TDoubleArrayList(int capacity) {
+ _data = new double[capacity];
+ _pos = 0;
+ }
+
+ /**
+ * Creates a new <code>TDoubleArrayList</code> instance whose
+ * capacity is the greater of the length of <tt>values</tt> and
+ * DEFAULT_CAPACITY and whose initial contents are the specified
+ * values.
+ *
+ * @param values an <code>double[]</code> value
+ */
+ public TDoubleArrayList(double[] values) {
+ this(Math.max(values.length, DEFAULT_CAPACITY));
+ add(values);
+ }
+
+ // sizing
+
+ /**
+ * Grow the internal array as needed to accomodate the specified
+ * number of elements. The size of the array doubles on each
+ * resize unless <tt>capacity</tt> requires more than twice the
+ * current capacity.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ public void ensureCapacity(int capacity) {
+ if (capacity > _data.length) {
+ int newCap = Math.max(_data.length << 1, capacity);
+ double[] tmp = new double[newCap];
+ System.arraycopy(_data, 0, tmp, 0, _data.length);
+ _data = tmp;
+ }
+ }
+
+ /**
+ * Returns the number of values in the list.
+ *
+ * @return the number of values in the list.
+ */
+ public int size() {
+ return _pos;
+ }
+
+ /**
+ * Tests whether this list contains any values.
+ *
+ * @return true if the list is empty.
+ */
+ public boolean isEmpty() {
+ return _pos == 0;
+ }
+
+ /**
+ * Sheds any excess capacity above and beyond the current size of
+ * the list.
+ */
+ public void trimToSize() {
+ if (_data.length > size()) {
+ double[] tmp = new double[size()];
+ toNativeArray(tmp, 0, tmp.length);
+ _data = tmp;
+ }
+ }
+
+ // modifying
+
+ /**
+ * Adds <tt>val</tt> to the end of the list, growing as needed.
+ *
+ * @param val an <code>double</code> value
+ */
+ public void add(double val) {
+ ensureCapacity(_pos + 1);
+ _data[_pos++] = val;
+ }
+
+ /**
+ * Adds the values in the array <tt>vals</tt> to the end of the
+ * list, in order.
+ *
+ * @param vals an <code>double[]</code> value
+ */
+ public void add(double[] vals) {
+ add(vals, 0, vals.length);
+ }
+
+ /**
+ * Adds a subset of the values in the array <tt>vals</tt> to the
+ * end of the list, in order.
+ *
+ * @param vals an <code>double[]</code> value
+ * @param offset the offset at which to start copying
+ * @param length the number of values to copy.
+ */
+ public void add(double[] vals, int offset, int length) {
+ ensureCapacity(_pos + length);
+ System.arraycopy(vals, offset, _data, _pos, length);
+ _pos += length;
+ }
+
+ /**
+ * Inserts <tt>value</tt> into the list at <tt>offset</tt>. All
+ * values including and to the right of <tt>offset</tt> are shifted
+ * to the right.
+ *
+ * @param offset an <code>int</code> value
+ * @param value an <code>double</code> value
+ */
+ public void insert(int offset, double value) {
+ if (offset == _pos) {
+ add(value);
+ return;
+ }
+ ensureCapacity(_pos + 1);
+ // shift right
+ System.arraycopy(_data, offset, _data, offset + 1, _pos - offset);
+ // insert
+ _data[offset] = value;
+ _pos++;
+ }
+
+ /**
+ * Inserts the array of <tt>values</tt> into the list at
+ * <tt>offset</tt>. All values including and to the right of
+ * <tt>offset</tt> are shifted to the right.
+ *
+ * @param offset an <code>int</code> value
+ * @param values an <code>double[]</code> value
+ */
+ public void insert(int offset, double[] values) {
+ insert(offset, values, 0, values.length);
+ }
+
+ /**
+ * Inserts a slice of the array of <tt>values</tt> into the list
+ * at <tt>offset</tt>. All values including and to the right of
+ * <tt>offset</tt> are shifted to the right.
+ *
+ * @param offset an <code>int</code> value
+ * @param values an <code>double[]</code> value
+ * @param valOffset the offset in the values array at which to
+ * start copying.
+ * @param len the number of values to copy from the values array
+ */
+ public void insert(int offset, double[] values, int valOffset, int len) {
+ if (offset == _pos) {
+ add(values, valOffset, len);
+ return;
+ }
+
+ ensureCapacity(_pos + len);
+ // shift right
+ System.arraycopy(_data, offset, _data, offset + len, _pos - offset);
+ // insert
+ System.arraycopy(values, valOffset, _data, offset, len);
+ _pos += len;
+ }
+
+ /**
+ * Returns the value at the specified offset.
+ *
+ * @param offset an <code>int</code> value
+ * @return an <code>double</code> value
+ */
+ public double get(int offset) {
+ if (offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ return _data[offset];
+ }
+
+ /**
+ * Returns the value at the specified offset without doing any
+ * bounds checking.
+ *
+ * @param offset an <code>int</code> value
+ * @return an <code>double</code> value
+ */
+ public double getQuick(int offset) {
+ return _data[offset];
+ }
+
+ /**
+ * Sets the value at the specified offset.
+ *
+ * @param offset an <code>int</code> value
+ * @param val an <code>double</code> value
+ */
+ public void set(int offset, double val) {
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ _data[offset] = val;
+ }
+
+ /**
+ * Sets the value at the specified offset and returns the
+ * previously stored value.
+ *
+ * @param offset an <code>int</code> value
+ * @param val an <code>double</code> value
+ * @return the value previously stored at offset.
+ */
+ public double getSet(int offset, double val) {
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ double old = _data[offset];
+ _data[offset] = val;
+ return old;
+ }
+
+ /**
+ * Replace the values in the list starting at <tt>offset</tt> with
+ * the contents of the <tt>values</tt> array.
+ *
+ * @param offset the first offset to replace
+ * @param values the source of the new values
+ */
+ public void set(int offset, double[] values) {
+ set(offset, values, 0, values.length);
+ }
+
+ /**
+ * Replace the values in the list starting at <tt>offset</tt> with
+ * <tt>length</tt> values from the <tt>values</tt> array, starting
+ * at valOffset.
+ *
+ * @param offset the first offset to replace
+ * @param values the source of the new values
+ * @param valOffset the first value to copy from the values array
+ * @param length the number of values to copy
+ */
+ public void set(int offset, double[] values, int valOffset, int length) {
+ if (offset < 0 || offset + length > _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ System.arraycopy(_data, offset, values, valOffset, length);
+ }
+
+ /**
+ * Sets the value at the specified offset without doing any bounds
+ * checking.
+ *
+ * @param offset an <code>int</code> value
+ * @param val an <code>double</code> value
+ */
+ public void setQuick(int offset, double val) {
+ _data[offset] = val;
+ }
+
+ /**
+ * Flushes the internal state of the list, resetting the capacity
+ * to the default.
+ */
+ public void clear() {
+ clear(DEFAULT_CAPACITY);
+ }
+
+ /**
+ * Flushes the internal state of the list, setting the capacity of
+ * the empty list to <tt>capacity</tt>.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ public void clear(int capacity) {
+ _data = new double[capacity];
+ _pos = 0;
+ }
+
+ /**
+ * Sets the size of the list to 0, but does not change its
+ * capacity. This method can be used as an alternative to the
+ * {@link #clear clear} method if you want to recyle a list without
+ * allocating new backing arrays.
+ *
+ * @see #clear
+ */
+ public void reset() {
+ _pos = 0;
+ fill(0);
+ }
+
+ /**
+ * Sets the size of the list to 0, but does not change its
+ * capacity. This method can be used as an alternative to the
+ * {@link #clear clear} method if you want to recyle a list
+ * without allocating new backing arrays. This method differs
+ * from {@link #reset reset} in that it does not clear the old
+ * values in the backing array. Thus, it is possible for {@link
+ * #getQuick getQuick} to return stale data if this method is used
+ * and the caller is careless about bounds checking.
+ *
+ * @see #reset
+ * @see #clear
+ * @see #getQuick
+ */
+ public void resetQuick() {
+ _pos = 0;
+ }
+
+ /**
+ * Removes the value at <tt>offset</tt> from the list.
+ *
+ * @param offset an <code>int</code> value
+ * @return the value previously stored at offset.
+ */
+ public double remove(int offset) {
+ double old = get(offset);
+ remove(offset, 1);
+ return old;
+ }
+
+ /**
+ * Removes <tt>length</tt> values from the list, starting at
+ * <tt>offset</tt>
+ *
+ * @param offset an <code>int</code> value
+ * @param length an <code>int</code> value
+ */
+ public void remove(int offset, int length) {
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+
+ if (offset == 0) {
+ // data at the front
+ System.arraycopy(_data, length, _data, 0, _pos - length);
+ } else if (_pos - length == offset) {
+ // no copy to make, decrementing pos "deletes" values at
+ // the end
+ } else {
+ // data in the middle
+ System.arraycopy(_data, offset + length,
+ _data, offset, _pos - (offset + length));
+ }
+ _pos -= length;
+ // no need to clear old values beyond _pos, because this is a
+ // primitive collection and 0 takes as much room as any other
+ // value
+ }
+
+ /**
+ * Transform each value in the list using the specified function.
+ *
+ * @param function a <code>TDoubleFunction</code> value
+ */
+ public void transformValues(TDoubleFunction function) {
+ for (int i = _pos; i-- > 0;) {
+ _data[i] = function.execute(_data[i]);
+ }
+ }
+
+ /**
+ * Reverse the order of the elements in the list.
+ */
+ public void reverse() {
+ reverse(0, _pos);
+ }
+
+ /**
+ * Reverse the order of the elements in the range of the list.
+ *
+ * @param from the inclusive index at which to start reversing
+ * @param to the exclusive index at which to stop reversing
+ */
+ public void reverse(int from, int to) {
+ if (from == to) {
+ return; // nothing to do
+ }
+ if (from > to) {
+ throw new IllegalArgumentException("from cannot be greater than to");
+ }
+ for (int i = from, j = to - 1; i < j; i++, j--) {
+ swap(i, j);
+ }
+ }
+
+ /**
+ * Shuffle the elements of the list using the specified random
+ * number generator.
+ *
+ * @param rand a <code>Random</code> value
+ */
+ public void shuffle(Random rand) {
+ for (int i = _pos; i-- > 1;) {
+ swap(i, rand.nextInt(i));
+ }
+ }
+
+ /**
+ * Swap the values at offsets <tt>i</tt> and <tt>j</tt>.
+ *
+ * @param i an offset into the data array
+ * @param j an offset into the data array
+ */
+ private void swap(int i, int j) {
+ double tmp = _data[i];
+ _data[i] = _data[j];
+ _data[j] = tmp;
+ }
+
+ // copying
+
+ /**
+ * Returns a clone of this list. Since this is a primitive
+ * collection, this will be a deep clone.
+ *
+ * @return a deep clone of the list.
+ */
+ @Override
+ public Object clone() {
+ TDoubleArrayList clone = null;
+ try {
+ clone = (TDoubleArrayList)super.clone();
+ clone._data = _data.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ // it's supported
+ } // end of try-catch
+ return clone;
+ }
+
+ /**
+ * Copies the contents of the list into a native array.
+ *
+ * @return an <code>double[]</code> value
+ */
+ public double[] toNativeArray() {
+ return toNativeArray(0, _pos);
+ }
+
+ /**
+ * Copies a slice of the list into a native array.
+ *
+ * @param offset the offset at which to start copying
+ * @param len the number of values to copy.
+ * @return an <code>double[]</code> value
+ */
+ public double[] toNativeArray(int offset, int len) {
+ double[] rv = new double[len];
+ toNativeArray(rv, offset, len);
+ return rv;
+ }
+
+ /**
+ * Copies a slice of the list into a native array.
+ *
+ * @param dest the array to copy into.
+ * @param offset the offset of the first value to copy
+ * @param len the number of values to copy.
+ */
+ public void toNativeArray(double[] dest, int offset, int len) {
+ if (len == 0) {
+ return; // nothing to copy
+ }
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ System.arraycopy(_data, offset, dest, 0, len);
+ }
+
+ // comparing
+
+ /**
+ * Compares this list to another list, value by value.
+ *
+ * @param other the object to compare against
+ * @return true if other is a TDoubleArrayList and has exactly the
+ * same values.
+ */
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ } else if (other instanceof TDoubleArrayList) {
+ TDoubleArrayList that = (TDoubleArrayList)other;
+ if (that.size() != this.size()) {
+ return false;
+ } else {
+ for (int i = _pos; i-- > 0;) {
+ if (this._data[i] != that._data[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ int h = 0;
+ for (int i = _pos; i-- > 0;) {
+ h += HashFunctions.hash(_data[i]);
+ }
+ return h;
+ }
+
+ // procedures
+
+ /**
+ * Applies the procedure to each value in the list in ascending
+ * (front to back) order.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return true if the procedure did not terminate prematurely.
+ */
+ public boolean forEach(TDoubleProcedure procedure) {
+ for (int i = 0; i < _pos; i++) {
+ if (! procedure.execute(_data[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Applies the procedure to each value in the list in descending
+ * (back to front) order.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return true if the procedure did not terminate prematurely.
+ */
+ public boolean forEachDescending(TDoubleProcedure procedure) {
+ for (int i = _pos; i-- > 0;) {
+ if (! procedure.execute(_data[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // sorting
+
+ /**
+ * Sort the values in the list (ascending) using the Sun quicksort
+ * implementation.
+ *
+ * @see java.util.Arrays#sort
+ */
+ public void sort() {
+ Arrays.sort(_data, 0, _pos);
+ }
+
+ /**
+ * Sort a slice of the list (ascending) using the Sun quicksort
+ * implementation.
+ *
+ * @param fromIndex the index at which to start sorting (inclusive)
+ * @param toIndex the index at which to stop sorting (exclusive)
+ * @see java.util.Arrays#sort
+ */
+ public void sort(int fromIndex, int toIndex) {
+ Arrays.sort(_data, fromIndex, toIndex);
+ }
+
+ // filling
+
+ /**
+ * Fills every slot in the list with the specified value.
+ *
+ * @param val the value to use when filling
+ */
+ public void fill(double val) {
+ Arrays.fill(_data, 0, _pos, val);
+ }
+
+ /**
+ * Fills a range in the list with the specified value.
+ *
+ * @param fromIndex the offset at which to start filling (inclusive)
+ * @param toIndex the offset at which to stop filling (exclusive)
+ * @param val the value to use when filling
+ */
+ public void fill(int fromIndex, int toIndex, double val) {
+ if (toIndex > _pos) {
+ ensureCapacity(toIndex);
+ _pos = toIndex;
+ }
+ Arrays.fill(_data, fromIndex, toIndex, val);
+ }
+
+ // searching
+
+ /**
+ * Performs a binary search for <tt>value</tt> in the entire list.
+ * Note that you <b>must</b> {@link #sort sort} the list before
+ * doing a search.
+ *
+ * @param value the value to search for
+ * @return the absolute offset in the list of the value, or its
+ * negative insertion point into the sorted list.
+ */
+ public int binarySearch(double value) {
+ return binarySearch(value, 0, _pos);
+ }
+
+ /**
+ * Performs a binary search for <tt>value</tt> in the specified
+ * range. Note that you <b>must</b> {@link #sort sort} the list
+ * or the range before doing a search.
+ *
+ * @param value the value to search for
+ * @param fromIndex the lower boundary of the range (inclusive)
+ * @param toIndex the upper boundary of the range (exclusive)
+ * @return the absolute offset in the list of the value, or its
+ * negative insertion point into the sorted list.
+ */
+ public int binarySearch(double value, int fromIndex, int toIndex) {
+ if (fromIndex < 0) {
+ throw new ArrayIndexOutOfBoundsException(fromIndex);
+ }
+ if (toIndex > _pos) {
+ throw new ArrayIndexOutOfBoundsException(toIndex);
+ }
+
+ int low = fromIndex;
+ int high = toIndex - 1;
+
+ while (low <= high) {
+ int mid = (low + high) >> 1;
+ double midVal = _data[mid];
+
+ if (midVal < value) {
+ low = mid + 1;
+ } else if (midVal > value) {
+ high = mid - 1;
+ } else {
+ return mid; // value found
+ }
+ }
+ return -(low + 1); // value not found.
+ }
+
+ /**
+ * Searches the list front to back for the index of
+ * <tt>value</tt>.
+ *
+ * @param value an <code>double</code> value
+ * @return the first offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int indexOf(double value) {
+ return indexOf(0, value);
+ }
+
+ /**
+ * Searches the list front to back for the index of
+ * <tt>value</tt>, starting at <tt>offset</tt>.
+ *
+ * @param offset the offset at which to start the linear search
+ * (inclusive)
+ * @param value an <code>double</code> value
+ * @return the first offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int indexOf(int offset, double value) {
+ for (int i = offset; i < _pos; i++) {
+ if (_data[i] == value) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Searches the list back to front for the last index of
+ * <tt>value</tt>.
+ *
+ * @param value an <code>double</code> value
+ * @return the last offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int lastIndexOf(double value) {
+ return lastIndexOf(_pos, value);
+ }
+
+ /**
+ * Searches the list back to front for the last index of
+ * <tt>value</tt>, starting at <tt>offset</tt>.
+ *
+ * @param offset the offset at which to start the linear search
+ * (exclusive)
+ * @param value an <code>double</code> value
+ * @return the last offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int lastIndexOf(int offset, double value) {
+ for (int i = offset; i-- > 0;) {
+ if (_data[i] == value) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Searches the list for <tt>value</tt>
+ *
+ * @param value an <code>double</code> value
+ * @return true if value is in the list.
+ */
+ public boolean contains(double value) {
+ return lastIndexOf(value) >= 0;
+ }
+
+ /**
+ * Searches the list for values satisfying <tt>condition</tt> in
+ * the manner of the *nix <tt>grep</tt> utility.
+ *
+ * @param condition a condition to apply to each element in the list
+ * @return a list of values which match the condition.
+ */
+ public TDoubleArrayList grep(TDoubleProcedure condition) {
+ TDoubleArrayList list = new TDoubleArrayList();
+ for (int i = 0; i < _pos; i++) {
+ if (condition.execute(_data[i])) {
+ list.add(_data[i]);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Searches the list for values which do <b>not</b> satisfy
+ * <tt>condition</tt>. This is akin to *nix <code>grep -v</code>.
+ *
+ * @param condition a condition to apply to each element in the list
+ * @return a list of values which do not match the condition.
+ */
+ public TDoubleArrayList inverseGrep(TDoubleProcedure condition) {
+ TDoubleArrayList list = new TDoubleArrayList();
+ for (int i = 0; i < _pos; i++) {
+ if (! condition.execute(_data[i])) {
+ list.add(_data[i]);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Finds the maximum value in the list.
+ *
+ * @return the largest value in the list.
+ * @exception IllegalStateException if the list is empty
+ */
+ public double max() {
+ if (size() == 0) {
+ throw new IllegalStateException("cannot find maximum of an empty list");
+ }
+ double max = _data[_pos - 1];
+ for (int i = _pos - 1; i-- > 0;) {
+ max = Math.max(max, _data[_pos]);
+ }
+ return max;
+ }
+
+ /**
+ * Finds the minimum value in the list.
+ *
+ * @return the smallest value in the list.
+ * @exception IllegalStateException if the list is empty
+ */
+ public double min() {
+ if (size() == 0) {
+ throw new IllegalStateException("cannot find minimum of an empty list");
+ }
+ double min = _data[_pos - 1];
+ for (int i = _pos - 1; i-- > 0;) {
+ min = Math.min(min, _data[_pos]);
+ }
+ return min;
+ }
+
+ // stringification
+
+ /**
+ * Returns a String representation of the list, front to back.
+ *
+ * @return a <code>String</code> value
+ */
+ public String toString() {
+ final StringBuffer buf = new StringBuffer("{");
+ forEach(new TDoubleProcedure() {
+ @Override
+ public boolean execute(double val) {
+ buf.append(val);
+ buf.append(", ");
+ return true;
+ }
+ });
+ buf.append("}");
+ return buf.toString();
+ }
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(size());
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEach(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ _data = new double[size];
+ while (size-- > 0) {
+ double val = stream.readDouble();
+ add(val);
+ }
+ }
+
+} // TDoubleArrayList
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleDoubleHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleDoubleHashMap.java
new file mode 100755
index 0000000..6ae6dc8
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleDoubleHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for double keys and double values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TDoubleDoubleHashMap extends TDoubleHash {
+
+ /** the values of the map */
+ protected transient double[] _values;
+
+ /**
+ * Creates a new <code>TDoubleDoubleHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TDoubleDoubleHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TDoubleDoubleHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TDoubleDoubleHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TDoubleDoubleHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TDoubleDoubleHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TDoubleDoubleHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleDoubleHashMap(TDoubleHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TDoubleDoubleHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleDoubleHashMap(int initialCapacity, TDoubleHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TDoubleDoubleHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleDoubleHashMap(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TDoubleDoubleHashMap m = (TDoubleDoubleHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TDoubleDoubleIterator with access to this map's keys and values
+ */
+ public TDoubleDoubleIterator iterator() {
+ return new TDoubleDoubleIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new double[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>double</code> value
+ * @param value an <code>double</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public double put(double key, double value) {
+ double previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ double[] oldKeys = _set;
+ double[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new double[newCapacity];
+ _values = new double[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ double o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>double</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public double get(double key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ double[] keys = _set;
+ double[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>double</code> value
+ * @return an <code>double</code> value
+ */
+ public double remove(double key) {
+ double prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TDoubleDoubleHashMap)) {
+ return false;
+ }
+ TDoubleDoubleHashMap that = (TDoubleDoubleHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TDoubleDoubleProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(double key, double value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TDoubleDoubleProcedure {
+ private final TDoubleDoubleHashMap _otherMap;
+
+ EqProcedure(TDoubleDoubleHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(double key, double value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two doubles for equality.
+ */
+ private static boolean eq(double v1, double v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public double[] getValues() {
+ double[] vals = new double[size()];
+ double[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public double[] keys() {
+ double[] keys = new double[size()];
+ double[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>double</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(double val) {
+ byte[] states = _states;
+ double[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>double</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(double key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TDoubleProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TDoubleProcedure procedure) {
+ byte[] states = _states;
+ double[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TDoubleDoubleProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TDoubleDoubleProcedure procedure) {
+ byte[] states = _states;
+ double[] keys = _set;
+ double[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TDoubleDoubleProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ double[] keys = _set;
+ double[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TDoubleFunction</code> value
+ */
+ public void transformValues(TDoubleFunction function) {
+ byte[] states = _states;
+ double[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(double key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(double key, double amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ double key = stream.readDouble();
+ double val = stream.readDouble();
+ put(key, val);
+ }
+ }
+} // TDoubleDoubleHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleDoubleIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleDoubleIterator.java
new file mode 100755
index 0000000..2e3d3af
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleDoubleIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type double and double.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TDoubleDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TDoubleDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TDoubleDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TDoubleDoubleIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TDoubleDoubleIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TDoubleDoubleHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TDoubleDoubleIterator(TDoubleDoubleHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public double key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public double value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public double setValue(double val) {
+ double old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TDoubleDoubleIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleDoubleProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleDoubleProcedure.java
new file mode 100755
index 0000000..95966e6
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleDoubleProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type double and double.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TDoubleDoubleProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>double</code> value
+ * @param b an <code>double</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(double a, double b);
+}// TDoubleDoubleProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleFloatHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleFloatHashMap.java
new file mode 100755
index 0000000..54173a0
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleFloatHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for double keys and float values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TDoubleFloatHashMap extends TDoubleHash {
+
+ /** the values of the map */
+ protected transient float[] _values;
+
+ /**
+ * Creates a new <code>TDoubleFloatHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TDoubleFloatHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TDoubleFloatHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TDoubleFloatHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TDoubleFloatHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TDoubleFloatHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TDoubleFloatHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleFloatHashMap(TDoubleHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TDoubleFloatHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleFloatHashMap(int initialCapacity, TDoubleHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TDoubleFloatHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleFloatHashMap(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TDoubleFloatHashMap m = (TDoubleFloatHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TDoubleFloatIterator with access to this map's keys and values
+ */
+ public TDoubleFloatIterator iterator() {
+ return new TDoubleFloatIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new float[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>double</code> value
+ * @param value an <code>float</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public float put(double key, float value) {
+ float previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ double[] oldKeys = _set;
+ float[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new double[newCapacity];
+ _values = new float[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ double o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>double</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public float get(double key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ double[] keys = _set;
+ float[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>double</code> value
+ * @return an <code>float</code> value
+ */
+ public float remove(double key) {
+ float prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TDoubleFloatHashMap)) {
+ return false;
+ }
+ TDoubleFloatHashMap that = (TDoubleFloatHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TDoubleFloatProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(double key, float value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TDoubleFloatProcedure {
+ private final TDoubleFloatHashMap _otherMap;
+
+ EqProcedure(TDoubleFloatHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(double key, float value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two floats for equality.
+ */
+ private static boolean eq(float v1, float v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public float[] getValues() {
+ float[] vals = new float[size()];
+ float[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public double[] keys() {
+ double[] keys = new double[size()];
+ double[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>float</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(float val) {
+ byte[] states = _states;
+ float[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>double</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(double key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TDoubleProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TFloatProcedure procedure) {
+ byte[] states = _states;
+ float[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TDoubleFloatProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TDoubleFloatProcedure procedure) {
+ byte[] states = _states;
+ double[] keys = _set;
+ float[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TDoubleFloatProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ double[] keys = _set;
+ float[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TFloatFunction</code> value
+ */
+ public void transformValues(TFloatFunction function) {
+ byte[] states = _states;
+ float[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(double key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(double key, float amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ double key = stream.readDouble();
+ float val = stream.readFloat();
+ put(key, val);
+ }
+ }
+} // TDoubleFloatHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleFloatIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleFloatIterator.java
new file mode 100755
index 0000000..b944ff1
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleFloatIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type double and float.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TDoubleFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TDoubleFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TDoubleFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TDoubleFloatIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TDoubleFloatIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TDoubleFloatHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TDoubleFloatIterator(TDoubleFloatHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public double key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public float value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public float setValue(float val) {
+ float old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TDoubleFloatIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleFloatProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleFloatProcedure.java
new file mode 100755
index 0000000..149dafe
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleFloatProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type double and float.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TDoubleFloatProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>double</code> value
+ * @param b an <code>float</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(double a, float b);
+}// TDoubleFloatProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleFunction.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleFunction.java
new file mode 100755
index 0000000..4cb80dd
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleFunction.java
@@ -0,0 +1,37 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for functions that accept and return one double primitive.
+ *
+ * Created: Mon Nov 5 22:19:36 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TDoubleFunction {
+ /**
+ * Execute this function with <tt>value</tt>
+ *
+ * @param value an <code>double</code> input
+ * @return an <code>double</code> result
+ */
+ double execute(double value);
+}// TDoubleFunction
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleHash.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleHash.java
new file mode 100755
index 0000000..ba68021
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleHash.java
@@ -0,0 +1,261 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * An open addressed hashing implementation for double primitives.
+ *
+ * Created: Sun Nov 4 08:56:06 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+abstract public class TDoubleHash extends TPrimitiveHash
+ implements TDoubleHashingStrategy {
+
+ /** the set of doubles */
+ protected transient double[] _set;
+
+ /** strategy used to hash values in this collection */
+ protected TDoubleHashingStrategy _hashingStrategy;
+
+ /**
+ * Creates a new <code>TDoubleHash</code> instance with the default
+ * capacity and load factor.
+ */
+ public TDoubleHash() {
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TDoubleHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TDoubleHash(int initialCapacity) {
+ super(initialCapacity);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TDoubleHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ */
+ public TDoubleHash(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TDoubleHash</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleHash(TDoubleHashingStrategy strategy) {
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TDoubleHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleHash(int initialCapacity, TDoubleHashingStrategy strategy) {
+ super(initialCapacity);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TDoubleHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleHash(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TDoubleHash h = (TDoubleHash)super.clone();
+ h._set = _set.clone();
+ return h;
+ }
+
+ /**
+ * initializes the hash table to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _set = new double[capacity];
+ return capacity;
+ }
+
+ /**
+ * Searches the set for <tt>val</tt>
+ *
+ * @param val an <code>double</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean contains(double val) {
+ return index(val) >= 0;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each element in the set.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the set terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEach(TDoubleProcedure procedure) {
+ byte[] states = _states;
+ double[] set = _set;
+ for (int i = set.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(set[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Releases the element currently stored at <tt>index</tt>.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _set[index] = (double)0;
+ super.removeAt(index);
+ }
+
+ /**
+ * Locates the index of <tt>val</tt>.
+ *
+ * @param val an <code>double</code> value
+ * @return the index of <tt>val</tt> or -1 if it isn't in the set.
+ */
+ protected int index(double val) {
+ byte[] states = _states;
+ double[] set = _set;
+ int length = states.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (states[index] != FREE &&
+ (states[index] == REMOVED || set[index] != val)) {
+ // see Knuth, p. 529
+ int probe = 1 + (hash % (length - 2));
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ } while (states[index] != FREE &&
+ (states[index] == REMOVED || set[index] != val));
+ }
+
+ return states[index] == FREE ? -1 : index;
+ }
+
+ /**
+ * Locates the index at which <tt>val</tt> can be inserted. if
+ * there is already a value equal()ing <tt>val</tt> in the set,
+ * returns that value as a negative integer.
+ *
+ * @param val an <code>double</code> value
+ * @return an <code>int</code> value
+ */
+ protected int insertionIndex(double val) {
+ byte[] states = _states;
+ double[] set = _set;
+ int length = states.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (states[index] == FREE) {
+ return index; // empty, all done
+ } else if (states[index] == FULL && set[index] == val) {
+ return -index -1; // already stored
+ } else { // already FULL or REMOVED, must probe
+ // compute the double hash
+ int probe = 1 + (hash % (length - 2));
+ // starting at the natural offset, probe until we find an
+ // offset that isn't full.
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ } while (states[index] == FULL && set[index] != val);
+
+ // if the index we found was removed: continue probing until we
+ // locate a free location or an element which equal()s the
+ // one we have.
+ if (states[index] == REMOVED) {
+ int firstRemoved = index;
+ while (states[index] != FREE &&
+ (states[index] == REMOVED || set[index] != val)) {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ }
+ return states[index] == FULL ? -index -1 : firstRemoved;
+ }
+ // if it's full, the key is already stored
+ return states[index] == FULL ? -index -1 : index;
+ }
+ }
+
+ /**
+ * Default implementation of TDoubleHashingStrategy:
+ * delegates hashing to HashFunctions.hash(double).
+ *
+ * @param val the value to hash
+ * @return the hash code.
+ */
+ @Override
+ public final int computeHashCode(double val) {
+ return HashFunctions.hash(val);
+ }
+} // TDoubleHash
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleHashSet.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleHashSet.java
new file mode 100755
index 0000000..ab62a96
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleHashSet.java
@@ -0,0 +1,363 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Arrays;
+
+/**
+ * An open addressed set implementation for double primitives.
+ *
+ * Created: Sat Nov 3 10:38:17 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TDoubleHashSet extends TDoubleHash {
+
+ /**
+ * Creates a new <code>TDoubleHashSet</code> instance with the default
+ * capacity and load factor.
+ */
+ public TDoubleHashSet() {
+ }
+
+ /**
+ * Creates a new <code>TDoubleHashSet</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TDoubleHashSet(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TDoubleHashSet</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TDoubleHashSet(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TDoubleHashSet</code> instance containing the
+ * elements of <tt>array</tt>.
+ *
+ * @param array an array of <code>double</code> primitives
+ */
+ public TDoubleHashSet(double[] array) {
+ this(array.length);
+ addAll(array);
+ }
+
+ /**
+ * Creates a new <code>TDoubleHash</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleHashSet(TDoubleHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TDoubleHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleHashSet(int initialCapacity, TDoubleHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TDoubleHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleHashSet(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * Creates a new <code>TDoubleHashSet</code> instance containing the
+ * elements of <tt>array</tt>.
+ *
+ * @param array an array of <code>double</code> primitives
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleHashSet(double[] array, TDoubleHashingStrategy strategy) {
+ this(array.length, strategy);
+ addAll(array);
+ }
+
+ /**
+ * @return a TDoubleIterator with access to the values in this set
+ */
+ public TDoubleIterator iterator() {
+ return new TDoubleIterator(this);
+ }
+
+ /**
+ * Inserts a value into the set.
+ *
+ * @param val an <code>double</code> value
+ * @return true if the set was modified by the add operation
+ */
+ public boolean add(double val) {
+ int index = insertionIndex(val);
+
+ if (index < 0) {
+ return false; // already present in set, nothing to add
+ }
+
+ byte previousState = _states[index];
+ _set[index] = val;
+ _states[index] = FULL;
+ postInsertHook(previousState == FREE);
+
+ return true; // yes, we added something
+ }
+
+ /**
+ * Expands the set to accommodate new values.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ double[] oldSet = _set;
+ byte[] oldStates = _states;
+
+ _set = new double[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ double o = oldSet[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * Returns a new array containing the values in the set.
+ *
+ * @return an <code>double[]</code> value
+ */
+ public double[] toArray() {
+ double[] result = new double[size()];
+ double[] set = _set;
+ byte[] states = _states;
+
+ for (int i = states.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ result[j++] = set[i];
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Empties the set.
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ double[] set = _set;
+ byte[] states = _states;
+
+ for (int i = set.length; i-- > 0;) {
+ set[i] = (double)0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Compares this set with another set for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TDoubleHashSet)) {
+ return false;
+ }
+ final TDoubleHashSet that = (TDoubleHashSet)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEach(new TDoubleProcedure() {
+ @Override
+ public final boolean execute(double value) {
+ return that.contains(value);
+ }
+ });
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEach(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TDoubleProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(double key) {
+ h += _hashingStrategy.computeHashCode(key);
+ return true;
+ }
+ }
+
+ /**
+ * Removes <tt>val</tt> from the set.
+ *
+ * @param val an <code>double</code> value
+ * @return true if the set was modified by the remove operation.
+ */
+ public boolean remove(double val) {
+ int index = index(val);
+ if (index >= 0) {
+ removeAt(index);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Tests the set to determine if all of the elements in
+ * <tt>array</tt> are present.
+ *
+ * @param array an <code>array</code> of double primitives.
+ * @return true if all elements were present in the set.
+ */
+ public boolean containsAll(double[] array) {
+ for (int i = array.length; i-- > 0;) {
+ if (! contains(array[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Adds all of the elements in <tt>array</tt> to the set.
+ *
+ * @param array an <code>array</code> of double primitives.
+ * @return true if the set was modified by the add all operation.
+ */
+ public boolean addAll(double[] array) {
+ boolean changed = false;
+ for (int i = array.length; i-- > 0;) {
+ if (add(array[i])) {
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ /**
+ * Removes all of the elements in <tt>array</tt> from the set.
+ *
+ * @param array an <code>array</code> of double primitives.
+ * @return true if the set was modified by the remove all operation.
+ */
+ public boolean removeAll(double[] array) {
+ boolean changed = false;
+ for (int i = array.length; i-- > 0;) {
+ if (remove(array[i])) {
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ /**
+ * Removes any values in the set which are not contained in
+ * <tt>array</tt>.
+ *
+ * @param array an <code>array</code> of double primitives.
+ * @return true if the set was modified by the retain all operation
+ */
+ public boolean retainAll(double[] array) {
+ Arrays.sort(array);
+ double[] set = _set;
+ byte[] states = _states;
+
+ boolean changed = false;
+ for (int i = set.length; i-- > 0;) {
+ if (states[i] == FULL && Arrays.binarySearch(array,set[i]) < 0) {
+ remove(set[i]);
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEach(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ double val = stream.readDouble();
+ add(val);
+ }
+ }
+} // TDoubleHashSet
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleHashingStrategy.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleHashingStrategy.java
new file mode 100755
index 0000000..8b66dd7
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleHashingStrategy.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.Serializable;
+
+/**
+ * Interface to support pluggable hashing strategies in maps and sets.
+ * Implementors can use this interface to make the trove hashing
+ * algorithms use an optimal strategy when computing hashcodes.
+ *
+ * Created: Sun Nov 4 08:56:06 2001
+ *
+ * @author Eric D. Friedman
+ */
+public interface TDoubleHashingStrategy extends Serializable {
+ /**
+ * Computes a hash code for the specified double. Implementors
+ * can use the double's own value or a custom scheme designed to
+ * minimize collisions for a known set of input.
+ *
+ * @param val double for which the hashcode is to be computed
+ * @return the hashCode
+ */
+ public int computeHashCode(double val);
+} // TDoubleHashingStrategy
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleIntHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleIntHashMap.java
new file mode 100755
index 0000000..3f96766
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleIntHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for double keys and int values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TDoubleIntHashMap extends TDoubleHash {
+
+ /** the values of the map */
+ protected transient int[] _values;
+
+ /**
+ * Creates a new <code>TDoubleIntHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TDoubleIntHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TDoubleIntHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TDoubleIntHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TDoubleIntHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TDoubleIntHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TDoubleIntHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleIntHashMap(TDoubleHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TDoubleIntHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleIntHashMap(int initialCapacity, TDoubleHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TDoubleIntHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleIntHashMap(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TDoubleIntHashMap m = (TDoubleIntHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TDoubleIntIterator with access to this map's keys and values
+ */
+ public TDoubleIntIterator iterator() {
+ return new TDoubleIntIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new int[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>double</code> value
+ * @param value an <code>int</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public int put(double key, int value) {
+ int previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ double[] oldKeys = _set;
+ int[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new double[newCapacity];
+ _values = new int[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ double o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>double</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public int get(double key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ double[] keys = _set;
+ int[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>double</code> value
+ * @return an <code>int</code> value
+ */
+ public int remove(double key) {
+ int prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TDoubleIntHashMap)) {
+ return false;
+ }
+ TDoubleIntHashMap that = (TDoubleIntHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TDoubleIntProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(double key, int value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TDoubleIntProcedure {
+ private final TDoubleIntHashMap _otherMap;
+
+ EqProcedure(TDoubleIntHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(double key, int value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two ints for equality.
+ */
+ private static boolean eq(int v1, int v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public int[] getValues() {
+ int[] vals = new int[size()];
+ int[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public double[] keys() {
+ double[] keys = new double[size()];
+ double[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>int</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(int val) {
+ byte[] states = _states;
+ int[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>double</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(double key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TDoubleProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TIntProcedure procedure) {
+ byte[] states = _states;
+ int[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TDoubleIntProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TDoubleIntProcedure procedure) {
+ byte[] states = _states;
+ double[] keys = _set;
+ int[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TDoubleIntProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ double[] keys = _set;
+ int[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TIntFunction</code> value
+ */
+ public void transformValues(TIntFunction function) {
+ byte[] states = _states;
+ int[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(double key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(double key, int amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ double key = stream.readDouble();
+ int val = stream.readInt();
+ put(key, val);
+ }
+ }
+} // TDoubleIntHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleIntIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleIntIterator.java
new file mode 100755
index 0000000..4857095
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleIntIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type double and int.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TDoubleIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TDoubleIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TDoubleIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TDoubleIntIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TDoubleIntIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TDoubleIntHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TDoubleIntIterator(TDoubleIntHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public double key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public int value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public int setValue(int val) {
+ int old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TDoubleIntIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleIntProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleIntProcedure.java
new file mode 100755
index 0000000..741b282
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleIntProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type double and int.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TDoubleIntProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>double</code> value
+ * @param b an <code>int</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(double a, int b);
+}// TDoubleIntProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleIterator.java
new file mode 100755
index 0000000..22e5af4
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleIterator.java
@@ -0,0 +1,53 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for double collections.
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TDoubleIterator extends TPrimitiveIterator {
+ /**
+ * the collection on which the iterator operates
+ */
+ private final TDoubleHash _hash;
+
+ /**
+ * Creates a TDoubleIterator for the elements in the specified collection.
+ */
+ public TDoubleIterator(TDoubleHash hash) {
+ super(hash);
+ _hash = hash;
+ }
+
+ /**
+ * Advances the iterator to the next element in the underlying collection
+ * and returns it.
+ *
+ * @return the next double in the collection
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public double next() {
+ moveToNextIndex();
+ return _hash._set[_index];
+ }
+}// TDoubleIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleLongHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleLongHashMap.java
new file mode 100755
index 0000000..59bdd6e
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleLongHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for double keys and long values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TDoubleLongHashMap extends TDoubleHash {
+
+ /** the values of the map */
+ protected transient long[] _values;
+
+ /**
+ * Creates a new <code>TDoubleLongHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TDoubleLongHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TDoubleLongHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TDoubleLongHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TDoubleLongHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TDoubleLongHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TDoubleLongHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleLongHashMap(TDoubleHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TDoubleLongHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleLongHashMap(int initialCapacity, TDoubleHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TDoubleLongHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleLongHashMap(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TDoubleLongHashMap m = (TDoubleLongHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TDoubleLongIterator with access to this map's keys and values
+ */
+ public TDoubleLongIterator iterator() {
+ return new TDoubleLongIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new long[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>double</code> value
+ * @param value an <code>long</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public long put(double key, long value) {
+ long previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ double[] oldKeys = _set;
+ long[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new double[newCapacity];
+ _values = new long[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ double o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>double</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public long get(double key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ double[] keys = _set;
+ long[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>double</code> value
+ * @return an <code>long</code> value
+ */
+ public long remove(double key) {
+ long prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TDoubleLongHashMap)) {
+ return false;
+ }
+ TDoubleLongHashMap that = (TDoubleLongHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TDoubleLongProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(double key, long value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TDoubleLongProcedure {
+ private final TDoubleLongHashMap _otherMap;
+
+ EqProcedure(TDoubleLongHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(double key, long value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two longs for equality.
+ */
+ private static boolean eq(long v1, long v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public long[] getValues() {
+ long[] vals = new long[size()];
+ long[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public double[] keys() {
+ double[] keys = new double[size()];
+ double[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>long</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(long val) {
+ byte[] states = _states;
+ long[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>double</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(double key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TDoubleProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TLongProcedure procedure) {
+ byte[] states = _states;
+ long[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TDoubleLongProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TDoubleLongProcedure procedure) {
+ byte[] states = _states;
+ double[] keys = _set;
+ long[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TDoubleLongProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ double[] keys = _set;
+ long[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TLongFunction</code> value
+ */
+ public void transformValues(TLongFunction function) {
+ byte[] states = _states;
+ long[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(double key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(double key, long amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ double key = stream.readDouble();
+ long val = stream.readLong();
+ put(key, val);
+ }
+ }
+} // TDoubleLongHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleLongIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleLongIterator.java
new file mode 100755
index 0000000..b3ef1e9
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleLongIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type double and long.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TDoubleLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TDoubleLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TDoubleLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TDoubleLongIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TDoubleLongIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TDoubleLongHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TDoubleLongIterator(TDoubleLongHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public double key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public long value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public long setValue(long val) {
+ long old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TDoubleLongIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleLongProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleLongProcedure.java
new file mode 100755
index 0000000..a26ed19
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleLongProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type double and long.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TDoubleLongProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>double</code> value
+ * @param b an <code>long</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(double a, long b);
+}// TDoubleLongProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleObjectHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleObjectHashMap.java
new file mode 100755
index 0000000..96f0cc5
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleObjectHashMap.java
@@ -0,0 +1,668 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for double keys and Object values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TDoubleObjectHashMap<V> extends THash implements TDoubleHashingStrategy {
+
+ /** the values of the map */
+ protected transient V[] _values;
+
+ /** the set of doubles */
+ protected transient double[] _set;
+
+ /** strategy used to hash values in this collection */
+ protected final TDoubleHashingStrategy _hashingStrategy;
+
+ /**
+ * Creates a new <code>TDoubleObjectHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TDoubleObjectHashMap() {
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TDoubleObjectHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TDoubleObjectHashMap(int initialCapacity) {
+ super(initialCapacity);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TDoubleObjectHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TDoubleObjectHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TDoubleObjectHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleObjectHashMap(TDoubleHashingStrategy strategy) {
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TDoubleObjectHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleObjectHashMap(int initialCapacity, TDoubleHashingStrategy strategy) {
+ super(initialCapacity);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TDoubleObjectHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TDoubleObjectHashMap(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public TDoubleObjectHashMap<V> clone() {
+ TDoubleObjectHashMap<V> m = (TDoubleObjectHashMap<V>)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TDoubleObjectIterator with access to this map's keys and values
+ */
+ public TDoubleObjectIterator<V> iterator() {
+ return new TDoubleObjectIterator<V>(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = (V[]) new Object[capacity];
+ _set = new double[capacity];
+
+ return capacity;
+ }
+
+ /**
+ * Searches the set for <tt>val</tt>
+ *
+ * @param val an <code>double</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean contains(double val) {
+ return index(val) >= 0;
+ }
+
+
+ /**
+ * Returns the capacity of the hash table. This is the true
+ * physical capacity, without adjusting for the load factor.
+ *
+ * @return the physical capacity of the hash table.
+ */
+ @Override
+ protected int capacity() {
+ return _values.length;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each element in the set.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return false if the loop over the set terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEach(TDoubleProcedure procedure) {
+ double[] set = _set;
+ Object[] values = _values;
+ for (int i = set.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(set[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>double</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public V put(double key, V value) {
+ boolean wasFree = false;
+ V previous = null;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = unwrapNull(_values[index]);
+ isNewMapping = false;
+ }
+ else {
+ wasFree = isFree(_values, index);
+ }
+ _set[index] = key;
+ _values[index] = wrapNull(value);
+ if (isNewMapping) {
+ postInsertHook(wasFree);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ double[] oldKeys = _set;
+ V[] oldVals = _values;
+
+ _set = new double[newCapacity];
+ _values = (V[]) new Object[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(isFull(oldVals, i)) {
+ double o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>double</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public V get(double key) {
+ int index = index(key);
+ return index < 0 ? null : unwrapNull(_values[index]);
+ }
+
+ private static <V> V unwrapNull(V value) {
+ return value == TObjectHash.NULL ? null : value;
+ }
+ private static <V> V wrapNull(V value) {
+ return value == null ? (V)TObjectHash.NULL : value;
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ double[] keys = _set;
+ Object[] values = _values;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = (double)0;
+ values[i] = null;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>double</code> value
+ * @return an <code>Object</code> value
+ */
+ public V remove(double key) {
+ V prev = null;
+ int index = index(key);
+ if (index >= 0) {
+ prev = unwrapNull(_values[index]);
+ removeAt(index); // clear key,set; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Locates the index of <tt>val</tt>.
+ *
+ * @param val an <code>double</code> value
+ * @return the index of <tt>val</tt> or -1 if it isn't in the set.
+ */
+ protected int index(double val) {
+ double[] set = _set;
+ Object[] values = _values;
+ int length = set.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (!isFree(values, index) &&
+ (isRemoved(values, index) || set[index] != val)) {
+ // see Knuth, p. 529
+ int probe = 1 + (hash % (length - 2));
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ } while (!isFree(values, index) &&
+ (isRemoved(values, index) || set[index] != val));
+ }
+
+ return isFree(values, index) ? -1 : index;
+ }
+
+ /**
+ * Locates the index at which <tt>val</tt> can be inserted. if
+ * there is already a value equal()ing <tt>val</tt> in the set,
+ * returns that value as a negative integer.
+ *
+ * @param val an <code>double</code> value
+ * @return an <code>int</code> value
+ */
+ protected int insertionIndex(double val) {
+ Object[] values = _values;
+ double[] set = _set;
+ int length = set.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (isFree(values, index)) {
+ return index; // empty, all done
+ }
+ if (isFull(values, index) && set[index] == val) {
+ return -index -1; // already stored
+ }
+
+ // already FULL or REMOVED, must probe
+ // compute the double hash
+ int probe = 1 + (hash % (length - 2));
+ // starting at the natural offset, probe until we find an
+ // offset that isn't full.
+
+ // keep track of the first removed cell. it's the natural candidate for re-insertion
+ int firstRemoved = isRemoved(values, index) ? index : -1;
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ if (firstRemoved == -1 && isRemoved(values, index)) {
+ firstRemoved = index;
+ }
+ }
+ while (isFull(values, index) && set[index] != val);
+
+ // if the index we found was removed: continue probing until we
+ // locate a free location or an element which equal()s the
+ // one we have.
+ if (isRemoved(values, index)) {
+ while (!isFree(values, index) &&
+ (isRemoved(values, index) || set[index] != val)) {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ }
+ }
+ // if it's full, the key is already stored
+ if (isFull(values, index)) {
+ return -index -1;
+ }
+
+ return firstRemoved == -1 ? index : firstRemoved;
+ }
+
+ static boolean isFull(Object[] values, int index) {
+ Object value = values[index];
+ return value != null && value != TObjectHash.REMOVED;
+ }
+
+ private static boolean isRemoved(Object[] values, int index) {
+ return values[index] == TObjectHash.REMOVED;
+ }
+
+ private static boolean isFree(Object[] values, int index) {
+ return values[index] == null;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TDoubleObjectHashMap)) {
+ return false;
+ }
+ TDoubleObjectHashMap that = (TDoubleObjectHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure<V>(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TDoubleObjectProcedure<V> {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(double key, V value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure<V> implements TDoubleObjectProcedure<V> {
+ private final TDoubleObjectHashMap<V> _otherMap;
+
+ EqProcedure(TDoubleObjectHashMap<V> otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(double key, V value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two objects for equality.
+ */
+ private static boolean eq(Object o1, Object o2) {
+ return o1 == o2 || o1 != null && o1.equals(o2);
+ }
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = (V)TObjectHash.REMOVED;
+ super.removeAt(index); // clear key, set; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a value <code>array</code>
+ */
+ public Object[] getValues() {
+ Object[] vals = new Object[size()];
+ V[] values = _values;
+
+ for (int i = values.length, j = 0; i-- > 0;) {
+ if (isFull(values, i)) {
+ vals[j++] = unwrapNull(values[i]);
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public double[] keys() {
+ double[] keys = new double[size()];
+ double[] k = _set;
+ Object[] values = _values;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (isFull(values, i)) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(V val) {
+ V[] values = _values;
+
+ // special case null values so that we don't have to
+ // perform null checks before every call to equals()
+ if (null == val) {
+ for (int i = values.length; i-- > 0;) {
+ if (TObjectHash.NULL == values[i]) {
+ return true;
+ }
+ }
+ }
+ else {
+ for (int i = values.length; i-- > 0;) {
+ V value = unwrapNull(values[i]);
+ if (isFull(values, i) && (val == value || val.equals(value))) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>double</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(double key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TDoubleProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TObjectProcedure<V> procedure) {
+ V[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(unwrapNull(values[i]))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TODoubleObjectProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TDoubleObjectProcedure<V> procedure) {
+ double[] keys = _set;
+ V[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(keys[i],unwrapNull(values[i]))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TDoubleObjectProcedure<V> procedure) {
+ boolean modified = false;
+ double[] keys = _set;
+ V[] values = _values;
+ stopCompactingOnRemove();
+ try {
+ for (int i = keys.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(keys[i],unwrapNull(values[i]))) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ }
+ finally {
+ startCompactingOnRemove(modified);
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TObjectFunction</code> value
+ */
+ public void transformValues(TObjectFunction<V,V> function) {
+ V[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (isFull(values, i)) {
+ values[i] = wrapNull(function.execute(unwrapNull(values[i])));
+ }
+ }
+ }
+
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ double key = stream.readDouble();
+ V val = (V) stream.readObject();
+ put(key, val);
+ }
+ }
+
+ /**
+ * Default implementation of TDoubleHashingStrategy:
+ * delegates hashing to HashFunctions.hash(double).
+ *
+ * @param val the value to hash
+ * @return the hashcode.
+ */
+ @Override
+ public final int computeHashCode(double val) {
+ return HashFunctions.hash(val);
+ }
+
+} // TDoubleObjectHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleObjectIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleObjectIterator.java
new file mode 100755
index 0000000..c3ae544
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleObjectIterator.java
@@ -0,0 +1,168 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.util.ConcurrentModificationException;
+
+/**
+ * Iterator for maps of type double and Object.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TDoubleObjectIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TDoubleObjectIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TDoubleObjectIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TDoubleObjectIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+public class TDoubleObjectIterator <V> extends TIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TDoubleObjectHashMap<V> _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TDoubleObjectIterator(TDoubleObjectHashMap<V> map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Returns the index of the next value in the data structure
+ * or a negative value if the iterator is exhausted.
+ *
+ * @return an <code>int</code> value
+ * @exception ConcurrentModificationException if the underlying collection's
+ * size has been modified since the iterator was created.
+ */
+ @Override
+ protected final int nextIndex() {
+ if (_expectedSize != _map.size()) {
+ throw new ConcurrentModificationException();
+ }
+
+ Object[] values = _map._values;
+ int i = _index;
+ while (i-- > 0 && !TDoubleObjectHashMap.isFull(values, i));
+ return i;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public double key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public V value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public V setValue(V val) {
+ V old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TDoubleObjectIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleObjectProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleObjectProcedure.java
new file mode 100755
index 0000000..f0d3400
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleObjectProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type double and Object.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TDoubleObjectProcedure<V> {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>double</code> value
+ * @param b an <code>Object</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(double a, V b);
+}// TDoubleObjectProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleProcedure.java
new file mode 100755
index 0000000..1625ce9
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TDoubleProcedure.java
@@ -0,0 +1,40 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures with one double parameter.
+ *
+ * Created: Mon Nov 5 21:45:49 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TDoubleProcedure {
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param value a value of type <code>double</code>
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(double value);
+}// TDoubleProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatArrayList.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatArrayList.java
new file mode 100755
index 0000000..1cdd524
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatArrayList.java
@@ -0,0 +1,889 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Random;
+
+/**
+ * A resizable, array-backed list of float primitives.
+ *
+ * Created: Sat Dec 29 14:21:12 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TFloatArrayList implements Serializable, Cloneable {
+
+ /** the data of the list */
+ protected transient float[] _data;
+
+ /** the index after the last entry in the list */
+ protected transient int _pos;
+
+ /** the default capacity for new lists */
+ protected static final int DEFAULT_CAPACITY = 4;
+
+ /**
+ * Creates a new <code>TFloatArrayList</code> instance with the
+ * default capacity.
+ */
+ public TFloatArrayList() {
+ this(DEFAULT_CAPACITY);
+ }
+
+ /**
+ * Creates a new <code>TFloatArrayList</code> instance with the
+ * specified capacity.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ public TFloatArrayList(int capacity) {
+ _data = new float[capacity];
+ _pos = 0;
+ }
+
+ /**
+ * Creates a new <code>TFloatArrayList</code> instance whose
+ * capacity is the greater of the length of <tt>values</tt> and
+ * DEFAULT_CAPACITY and whose initial contents are the specified
+ * values.
+ *
+ * @param values an <code>float[]</code> value
+ */
+ public TFloatArrayList(float[] values) {
+ this(Math.max(values.length, DEFAULT_CAPACITY));
+ add(values);
+ }
+
+ // sizing
+
+ /**
+ * Grow the internal array as needed to accomodate the specified
+ * number of elements. The size of the array doubles on each
+ * resize unless <tt>capacity</tt> requires more than twice the
+ * current capacity.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ public void ensureCapacity(int capacity) {
+ if (capacity > _data.length) {
+ int newCap = Math.max(_data.length << 1, capacity);
+ float[] tmp = new float[newCap];
+ System.arraycopy(_data, 0, tmp, 0, _data.length);
+ _data = tmp;
+ }
+ }
+
+ /**
+ * Returns the number of values in the list.
+ *
+ * @return the number of values in the list.
+ */
+ public int size() {
+ return _pos;
+ }
+
+ /**
+ * Tests whether this list contains any values.
+ *
+ * @return true if the list is empty.
+ */
+ public boolean isEmpty() {
+ return _pos == 0;
+ }
+
+ /**
+ * Sheds any excess capacity above and beyond the current size of
+ * the list.
+ */
+ public void trimToSize() {
+ if (_data.length > size()) {
+ float[] tmp = new float[size()];
+ toNativeArray(tmp, 0, tmp.length);
+ _data = tmp;
+ }
+ }
+
+ // modifying
+
+ /**
+ * Adds <tt>val</tt> to the end of the list, growing as needed.
+ *
+ * @param val an <code>float</code> value
+ */
+ public void add(float val) {
+ ensureCapacity(_pos + 1);
+ _data[_pos++] = val;
+ }
+
+ /**
+ * Adds the values in the array <tt>vals</tt> to the end of the
+ * list, in order.
+ *
+ * @param vals an <code>float[]</code> value
+ */
+ public void add(float[] vals) {
+ add(vals, 0, vals.length);
+ }
+
+ /**
+ * Adds a subset of the values in the array <tt>vals</tt> to the
+ * end of the list, in order.
+ *
+ * @param vals an <code>float[]</code> value
+ * @param offset the offset at which to start copying
+ * @param length the number of values to copy.
+ */
+ public void add(float[] vals, int offset, int length) {
+ ensureCapacity(_pos + length);
+ System.arraycopy(vals, offset, _data, _pos, length);
+ _pos += length;
+ }
+
+ /**
+ * Inserts <tt>value</tt> into the list at <tt>offset</tt>. All
+ * values including and to the right of <tt>offset</tt> are shifted
+ * to the right.
+ *
+ * @param offset an <code>int</code> value
+ * @param value an <code>float</code> value
+ */
+ public void insert(int offset, float value) {
+ if (offset == _pos) {
+ add(value);
+ return;
+ }
+ ensureCapacity(_pos + 1);
+ // shift right
+ System.arraycopy(_data, offset, _data, offset + 1, _pos - offset);
+ // insert
+ _data[offset] = value;
+ _pos++;
+ }
+
+ /**
+ * Inserts the array of <tt>values</tt> into the list at
+ * <tt>offset</tt>. All values including and to the right of
+ * <tt>offset</tt> are shifted to the right.
+ *
+ * @param offset an <code>int</code> value
+ * @param values an <code>float[]</code> value
+ */
+ public void insert(int offset, float[] values) {
+ insert(offset, values, 0, values.length);
+ }
+
+ /**
+ * Inserts a slice of the array of <tt>values</tt> into the list
+ * at <tt>offset</tt>. All values including and to the right of
+ * <tt>offset</tt> are shifted to the right.
+ *
+ * @param offset an <code>int</code> value
+ * @param values an <code>float[]</code> value
+ * @param valOffset the offset in the values array at which to
+ * start copying.
+ * @param len the number of values to copy from the values array
+ */
+ public void insert(int offset, float[] values, int valOffset, int len) {
+ if (offset == _pos) {
+ add(values, valOffset, len);
+ return;
+ }
+
+ ensureCapacity(_pos + len);
+ // shift right
+ System.arraycopy(_data, offset, _data, offset + len, _pos - offset);
+ // insert
+ System.arraycopy(values, valOffset, _data, offset, len);
+ _pos += len;
+ }
+
+ /**
+ * Returns the value at the specified offset.
+ *
+ * @param offset an <code>int</code> value
+ * @return an <code>float</code> value
+ */
+ public float get(int offset) {
+ if (offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ return _data[offset];
+ }
+
+ /**
+ * Returns the value at the specified offset without doing any
+ * bounds checking.
+ *
+ * @param offset an <code>int</code> value
+ * @return an <code>float</code> value
+ */
+ public float getQuick(int offset) {
+ return _data[offset];
+ }
+
+ /**
+ * Sets the value at the specified offset.
+ *
+ * @param offset an <code>int</code> value
+ * @param val an <code>float</code> value
+ */
+ public void set(int offset, float val) {
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ _data[offset] = val;
+ }
+
+ /**
+ * Sets the value at the specified offset and returns the
+ * previously stored value.
+ *
+ * @param offset an <code>int</code> value
+ * @param val an <code>float</code> value
+ * @return the value previously stored at offset.
+ */
+ public float getSet(int offset, float val) {
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ float old = _data[offset];
+ _data[offset] = val;
+ return old;
+ }
+
+ /**
+ * Replace the values in the list starting at <tt>offset</tt> with
+ * the contents of the <tt>values</tt> array.
+ *
+ * @param offset the first offset to replace
+ * @param values the source of the new values
+ */
+ public void set(int offset, float[] values) {
+ set(offset, values, 0, values.length);
+ }
+
+ /**
+ * Replace the values in the list starting at <tt>offset</tt> with
+ * <tt>length</tt> values from the <tt>values</tt> array, starting
+ * at valOffset.
+ *
+ * @param offset the first offset to replace
+ * @param values the source of the new values
+ * @param valOffset the first value to copy from the values array
+ * @param length the number of values to copy
+ */
+ public void set(int offset, float[] values, int valOffset, int length) {
+ if (offset < 0 || offset + length > _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ System.arraycopy(_data, offset, values, valOffset, length);
+ }
+
+ /**
+ * Sets the value at the specified offset without doing any bounds
+ * checking.
+ *
+ * @param offset an <code>int</code> value
+ * @param val an <code>float</code> value
+ */
+ public void setQuick(int offset, float val) {
+ _data[offset] = val;
+ }
+
+ /**
+ * Flushes the internal state of the list, resetting the capacity
+ * to the default.
+ */
+ public void clear() {
+ clear(DEFAULT_CAPACITY);
+ }
+
+ /**
+ * Flushes the internal state of the list, setting the capacity of
+ * the empty list to <tt>capacity</tt>.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ public void clear(int capacity) {
+ _data = new float[capacity];
+ _pos = 0;
+ }
+
+ /**
+ * Sets the size of the list to 0, but does not change its
+ * capacity. This method can be used as an alternative to the
+ * {@link #clear clear} method if you want to recyle a list without
+ * allocating new backing arrays.
+ *
+ * @see #clear
+ */
+ public void reset() {
+ _pos = 0;
+ fill(0);
+ }
+
+ /**
+ * Sets the size of the list to 0, but does not change its
+ * capacity. This method can be used as an alternative to the
+ * {@link #clear clear} method if you want to recyle a list
+ * without allocating new backing arrays. This method differs
+ * from {@link #reset reset} in that it does not clear the old
+ * values in the backing array. Thus, it is possible for {@link
+ * #getQuick getQuick} to return stale data if this method is used
+ * and the caller is careless about bounds checking.
+ *
+ * @see #reset
+ * @see #clear
+ * @see #getQuick
+ */
+ public void resetQuick() {
+ _pos = 0;
+ }
+
+ /**
+ * Removes the value at <tt>offset</tt> from the list.
+ *
+ * @param offset an <code>int</code> value
+ * @return the value previously stored at offset.
+ */
+ public float remove(int offset) {
+ float old = get(offset);
+ remove(offset, 1);
+ return old;
+ }
+
+ /**
+ * Removes <tt>length</tt> values from the list, starting at
+ * <tt>offset</tt>
+ *
+ * @param offset an <code>int</code> value
+ * @param length an <code>int</code> value
+ */
+ public void remove(int offset, int length) {
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+
+ if (offset == 0) {
+ // data at the front
+ System.arraycopy(_data, length, _data, 0, _pos - length);
+ } else if (_pos - length == offset) {
+ // no copy to make, decrementing pos "deletes" values at
+ // the end
+ } else {
+ // data in the middle
+ System.arraycopy(_data, offset + length,
+ _data, offset, _pos - (offset + length));
+ }
+ _pos -= length;
+ // no need to clear old values beyond _pos, because this is a
+ // primitive collection and 0 takes as much room as any other
+ // value
+ }
+
+ /**
+ * Transform each value in the list using the specified function.
+ *
+ * @param function a <code>TFloatFunction</code> value
+ */
+ public void transformValues(TFloatFunction function) {
+ for (int i = _pos; i-- > 0;) {
+ _data[i] = function.execute(_data[i]);
+ }
+ }
+
+ /**
+ * Reverse the order of the elements in the list.
+ */
+ public void reverse() {
+ reverse(0, _pos);
+ }
+
+ /**
+ * Reverse the order of the elements in the range of the list.
+ *
+ * @param from the inclusive index at which to start reversing
+ * @param to the exclusive index at which to stop reversing
+ */
+ public void reverse(int from, int to) {
+ if (from == to) {
+ return; // nothing to do
+ }
+ if (from > to) {
+ throw new IllegalArgumentException("from cannot be greater than to");
+ }
+ for (int i = from, j = to - 1; i < j; i++, j--) {
+ swap(i, j);
+ }
+ }
+
+ /**
+ * Shuffle the elements of the list using the specified random
+ * number generator.
+ *
+ * @param rand a <code>Random</code> value
+ */
+ public void shuffle(Random rand) {
+ for (int i = _pos; i-- > 1;) {
+ swap(i, rand.nextInt(i));
+ }
+ }
+
+ /**
+ * Swap the values at offsets <tt>i</tt> and <tt>j</tt>.
+ *
+ * @param i an offset into the data array
+ * @param j an offset into the data array
+ */
+ private void swap(int i, int j) {
+ float tmp = _data[i];
+ _data[i] = _data[j];
+ _data[j] = tmp;
+ }
+
+ // copying
+
+ /**
+ * Returns a clone of this list. Since this is a primitive
+ * collection, this will be a deep clone.
+ *
+ * @return a deep clone of the list.
+ */
+ @Override
+ public Object clone() {
+ TFloatArrayList clone = null;
+ try {
+ clone = (TFloatArrayList)super.clone();
+ clone._data = _data.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ // it's supported
+ } // end of try-catch
+ return clone;
+ }
+
+ /**
+ * Copies the contents of the list into a native array.
+ *
+ * @return an <code>float[]</code> value
+ */
+ public float[] toNativeArray() {
+ return toNativeArray(0, _pos);
+ }
+
+ /**
+ * Copies a slice of the list into a native array.
+ *
+ * @param offset the offset at which to start copying
+ * @param len the number of values to copy.
+ * @return an <code>float[]</code> value
+ */
+ public float[] toNativeArray(int offset, int len) {
+ float[] rv = new float[len];
+ toNativeArray(rv, offset, len);
+ return rv;
+ }
+
+ /**
+ * Copies a slice of the list into a native array.
+ *
+ * @param dest the array to copy into.
+ * @param offset the offset of the first value to copy
+ * @param len the number of values to copy.
+ */
+ public void toNativeArray(float[] dest, int offset, int len) {
+ if (len == 0) {
+ return; // nothing to copy
+ }
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ System.arraycopy(_data, offset, dest, 0, len);
+ }
+
+ // comparing
+
+ /**
+ * Compares this list to another list, value by value.
+ *
+ * @param other the object to compare against
+ * @return true if other is a TFloatArrayList and has exactly the
+ * same values.
+ */
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ } else if (other instanceof TFloatArrayList) {
+ TFloatArrayList that = (TFloatArrayList)other;
+ if (that.size() != this.size()) {
+ return false;
+ } else {
+ for (int i = _pos; i-- > 0;) {
+ if (this._data[i] != that._data[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ int h = 0;
+ for (int i = _pos; i-- > 0;) {
+ h += HashFunctions.hash(_data[i]);
+ }
+ return h;
+ }
+
+ // procedures
+
+ /**
+ * Applies the procedure to each value in the list in ascending
+ * (front to back) order.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return true if the procedure did not terminate prematurely.
+ */
+ public boolean forEach(TFloatProcedure procedure) {
+ for (int i = 0; i < _pos; i++) {
+ if (! procedure.execute(_data[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Applies the procedure to each value in the list in descending
+ * (back to front) order.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return true if the procedure did not terminate prematurely.
+ */
+ public boolean forEachDescending(TFloatProcedure procedure) {
+ for (int i = _pos; i-- > 0;) {
+ if (! procedure.execute(_data[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // sorting
+
+ /**
+ * Sort the values in the list (ascending) using the Sun quicksort
+ * implementation.
+ *
+ * @see java.util.Arrays#sort
+ */
+ public void sort() {
+ Arrays.sort(_data, 0, _pos);
+ }
+
+ /**
+ * Sort a slice of the list (ascending) using the Sun quicksort
+ * implementation.
+ *
+ * @param fromIndex the index at which to start sorting (inclusive)
+ * @param toIndex the index at which to stop sorting (exclusive)
+ * @see java.util.Arrays#sort
+ */
+ public void sort(int fromIndex, int toIndex) {
+ Arrays.sort(_data, fromIndex, toIndex);
+ }
+
+ // filling
+
+ /**
+ * Fills every slot in the list with the specified value.
+ *
+ * @param val the value to use when filling
+ */
+ public void fill(float val) {
+ Arrays.fill(_data, 0, _pos, val);
+ }
+
+ /**
+ * Fills a range in the list with the specified value.
+ *
+ * @param fromIndex the offset at which to start filling (inclusive)
+ * @param toIndex the offset at which to stop filling (exclusive)
+ * @param val the value to use when filling
+ */
+ public void fill(int fromIndex, int toIndex, float val) {
+ if (toIndex > _pos) {
+ ensureCapacity(toIndex);
+ _pos = toIndex;
+ }
+ Arrays.fill(_data, fromIndex, toIndex, val);
+ }
+
+ // searching
+
+ /**
+ * Performs a binary search for <tt>value</tt> in the entire list.
+ * Note that you <b>must</b> {@link #sort sort} the list before
+ * doing a search.
+ *
+ * @param value the value to search for
+ * @return the absolute offset in the list of the value, or its
+ * negative insertion point into the sorted list.
+ */
+ public int binarySearch(float value) {
+ return binarySearch(value, 0, _pos);
+ }
+
+ /**
+ * Performs a binary search for <tt>value</tt> in the specified
+ * range. Note that you <b>must</b> {@link #sort sort} the list
+ * or the range before doing a search.
+ *
+ * @param value the value to search for
+ * @param fromIndex the lower boundary of the range (inclusive)
+ * @param toIndex the upper boundary of the range (exclusive)
+ * @return the absolute offset in the list of the value, or its
+ * negative insertion point into the sorted list.
+ */
+ public int binarySearch(float value, int fromIndex, int toIndex) {
+ if (fromIndex < 0) {
+ throw new ArrayIndexOutOfBoundsException(fromIndex);
+ }
+ if (toIndex > _pos) {
+ throw new ArrayIndexOutOfBoundsException(toIndex);
+ }
+
+ int low = fromIndex;
+ int high = toIndex - 1;
+
+ while (low <= high) {
+ int mid = (low + high) >> 1;
+ float midVal = _data[mid];
+
+ if (midVal < value) {
+ low = mid + 1;
+ } else if (midVal > value) {
+ high = mid - 1;
+ } else {
+ return mid; // value found
+ }
+ }
+ return -(low + 1); // value not found.
+ }
+
+ /**
+ * Searches the list front to back for the index of
+ * <tt>value</tt>.
+ *
+ * @param value an <code>float</code> value
+ * @return the first offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int indexOf(float value) {
+ return indexOf(0, value);
+ }
+
+ /**
+ * Searches the list front to back for the index of
+ * <tt>value</tt>, starting at <tt>offset</tt>.
+ *
+ * @param offset the offset at which to start the linear search
+ * (inclusive)
+ * @param value an <code>float</code> value
+ * @return the first offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int indexOf(int offset, float value) {
+ for (int i = offset; i < _pos; i++) {
+ if (_data[i] == value) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Searches the list back to front for the last index of
+ * <tt>value</tt>.
+ *
+ * @param value an <code>float</code> value
+ * @return the last offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int lastIndexOf(float value) {
+ return lastIndexOf(_pos, value);
+ }
+
+ /**
+ * Searches the list back to front for the last index of
+ * <tt>value</tt>, starting at <tt>offset</tt>.
+ *
+ * @param offset the offset at which to start the linear search
+ * (exclusive)
+ * @param value an <code>float</code> value
+ * @return the last offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int lastIndexOf(int offset, float value) {
+ for (int i = offset; i-- > 0;) {
+ if (_data[i] == value) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Searches the list for <tt>value</tt>
+ *
+ * @param value an <code>float</code> value
+ * @return true if value is in the list.
+ */
+ public boolean contains(float value) {
+ return lastIndexOf(value) >= 0;
+ }
+
+ /**
+ * Searches the list for values satisfying <tt>condition</tt> in
+ * the manner of the *nix <tt>grep</tt> utility.
+ *
+ * @param condition a condition to apply to each element in the list
+ * @return a list of values which match the condition.
+ */
+ public TFloatArrayList grep(TFloatProcedure condition) {
+ TFloatArrayList list = new TFloatArrayList();
+ for (int i = 0; i < _pos; i++) {
+ if (condition.execute(_data[i])) {
+ list.add(_data[i]);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Searches the list for values which do <b>not</b> satisfy
+ * <tt>condition</tt>. This is akin to *nix <code>grep -v</code>.
+ *
+ * @param condition a condition to apply to each element in the list
+ * @return a list of values which do not match the condition.
+ */
+ public TFloatArrayList inverseGrep(TFloatProcedure condition) {
+ TFloatArrayList list = new TFloatArrayList();
+ for (int i = 0; i < _pos; i++) {
+ if (! condition.execute(_data[i])) {
+ list.add(_data[i]);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Finds the maximum value in the list.
+ *
+ * @return the largest value in the list.
+ * @exception IllegalStateException if the list is empty
+ */
+ public float max() {
+ if (size() == 0) {
+ throw new IllegalStateException("cannot find maximum of an empty list");
+ }
+ float max = _data[_pos - 1];
+ for (int i = _pos - 1; i-- > 0;) {
+ max = Math.max(max, _data[_pos]);
+ }
+ return max;
+ }
+
+ /**
+ * Finds the minimum value in the list.
+ *
+ * @return the smallest value in the list.
+ * @exception IllegalStateException if the list is empty
+ */
+ public float min() {
+ if (size() == 0) {
+ throw new IllegalStateException("cannot find minimum of an empty list");
+ }
+ float min = _data[_pos - 1];
+ for (int i = _pos - 1; i-- > 0;) {
+ min = Math.min(min, _data[_pos]);
+ }
+ return min;
+ }
+
+ // stringification
+
+ /**
+ * Returns a String representation of the list, front to back.
+ *
+ * @return a <code>String</code> value
+ */
+ public String toString() {
+ final StringBuffer buf = new StringBuffer("{");
+ forEach(new TFloatProcedure() {
+ @Override
+ public boolean execute(float val) {
+ buf.append(val);
+ buf.append(", ");
+ return true;
+ }
+ });
+ buf.append("}");
+ return buf.toString();
+ }
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(size());
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEach(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ _data = new float[size];
+ while (size-- > 0) {
+ float val = stream.readFloat();
+ add(val);
+ }
+ }
+
+} // TFloatArrayList
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatDoubleHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatDoubleHashMap.java
new file mode 100755
index 0000000..c0a944e
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatDoubleHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for float keys and double values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TFloatDoubleHashMap extends TFloatHash {
+
+ /** the values of the map */
+ protected transient double[] _values;
+
+ /**
+ * Creates a new <code>TFloatDoubleHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TFloatDoubleHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TFloatDoubleHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TFloatDoubleHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TFloatDoubleHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TFloatDoubleHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TFloatDoubleHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatDoubleHashMap(TFloatHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TFloatDoubleHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatDoubleHashMap(int initialCapacity, TFloatHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TFloatDoubleHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatDoubleHashMap(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TFloatDoubleHashMap m = (TFloatDoubleHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TFloatDoubleIterator with access to this map's keys and values
+ */
+ public TFloatDoubleIterator iterator() {
+ return new TFloatDoubleIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new double[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>float</code> value
+ * @param value an <code>double</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public double put(float key, double value) {
+ double previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ float[] oldKeys = _set;
+ double[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new float[newCapacity];
+ _values = new double[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ float o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>float</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public double get(float key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ float[] keys = _set;
+ double[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>float</code> value
+ * @return an <code>double</code> value
+ */
+ public double remove(float key) {
+ double prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TFloatDoubleHashMap)) {
+ return false;
+ }
+ TFloatDoubleHashMap that = (TFloatDoubleHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TFloatDoubleProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(float key, double value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TFloatDoubleProcedure {
+ private final TFloatDoubleHashMap _otherMap;
+
+ EqProcedure(TFloatDoubleHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(float key, double value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two doubles for equality.
+ */
+ private static boolean eq(double v1, double v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public double[] getValues() {
+ double[] vals = new double[size()];
+ double[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public float[] keys() {
+ float[] keys = new float[size()];
+ float[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>double</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(double val) {
+ byte[] states = _states;
+ double[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>float</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(float key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TFloatProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TDoubleProcedure procedure) {
+ byte[] states = _states;
+ double[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TFloatDoubleProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TFloatDoubleProcedure procedure) {
+ byte[] states = _states;
+ float[] keys = _set;
+ double[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TFloatDoubleProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ float[] keys = _set;
+ double[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TDoubleFunction</code> value
+ */
+ public void transformValues(TDoubleFunction function) {
+ byte[] states = _states;
+ double[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(float key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(float key, double amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ float key = stream.readFloat();
+ double val = stream.readDouble();
+ put(key, val);
+ }
+ }
+} // TFloatDoubleHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatDoubleIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatDoubleIterator.java
new file mode 100755
index 0000000..74f75cc
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatDoubleIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type float and double.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TFloatDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TFloatDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TFloatDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TFloatDoubleIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TFloatDoubleIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TFloatDoubleHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TFloatDoubleIterator(TFloatDoubleHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public float key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public double value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public double setValue(double val) {
+ double old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TFloatDoubleIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatDoubleProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatDoubleProcedure.java
new file mode 100755
index 0000000..cdd586b
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatDoubleProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type float and double.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TFloatDoubleProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>float</code> value
+ * @param b an <code>double</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(float a, double b);
+}// TFloatDoubleProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatFloatHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatFloatHashMap.java
new file mode 100755
index 0000000..32b03dd
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatFloatHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for float keys and float values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TFloatFloatHashMap extends TFloatHash {
+
+ /** the values of the map */
+ protected transient float[] _values;
+
+ /**
+ * Creates a new <code>TFloatFloatHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TFloatFloatHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TFloatFloatHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TFloatFloatHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TFloatFloatHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TFloatFloatHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TFloatFloatHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatFloatHashMap(TFloatHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TFloatFloatHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatFloatHashMap(int initialCapacity, TFloatHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TFloatFloatHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatFloatHashMap(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TFloatFloatHashMap m = (TFloatFloatHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TFloatFloatIterator with access to this map's keys and values
+ */
+ public TFloatFloatIterator iterator() {
+ return new TFloatFloatIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new float[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>float</code> value
+ * @param value an <code>float</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public float put(float key, float value) {
+ float previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ float[] oldKeys = _set;
+ float[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new float[newCapacity];
+ _values = new float[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ float o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>float</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public float get(float key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ float[] keys = _set;
+ float[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>float</code> value
+ * @return an <code>float</code> value
+ */
+ public float remove(float key) {
+ float prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TFloatFloatHashMap)) {
+ return false;
+ }
+ TFloatFloatHashMap that = (TFloatFloatHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TFloatFloatProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(float key, float value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TFloatFloatProcedure {
+ private final TFloatFloatHashMap _otherMap;
+
+ EqProcedure(TFloatFloatHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(float key, float value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two floats for equality.
+ */
+ private static boolean eq(float v1, float v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public float[] getValues() {
+ float[] vals = new float[size()];
+ float[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public float[] keys() {
+ float[] keys = new float[size()];
+ float[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>float</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(float val) {
+ byte[] states = _states;
+ float[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>float</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(float key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TFloatProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TFloatProcedure procedure) {
+ byte[] states = _states;
+ float[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TFloatFloatProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TFloatFloatProcedure procedure) {
+ byte[] states = _states;
+ float[] keys = _set;
+ float[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TFloatFloatProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ float[] keys = _set;
+ float[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TFloatFunction</code> value
+ */
+ public void transformValues(TFloatFunction function) {
+ byte[] states = _states;
+ float[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(float key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(float key, float amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ float key = stream.readFloat();
+ float val = stream.readFloat();
+ put(key, val);
+ }
+ }
+} // TFloatFloatHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatFloatIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatFloatIterator.java
new file mode 100755
index 0000000..51ee4da
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatFloatIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type float and float.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TFloatFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TFloatFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TFloatFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TFloatFloatIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TFloatFloatIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TFloatFloatHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TFloatFloatIterator(TFloatFloatHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public float key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public float value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public float setValue(float val) {
+ float old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TFloatFloatIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatFloatProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatFloatProcedure.java
new file mode 100755
index 0000000..cbc7f66
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatFloatProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type float and float.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TFloatFloatProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>float</code> value
+ * @param b an <code>float</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(float a, float b);
+}// TFloatFloatProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatFunction.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatFunction.java
new file mode 100755
index 0000000..254f408
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatFunction.java
@@ -0,0 +1,37 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for functions that accept and return one float primitive.
+ *
+ * Created: Mon Nov 5 22:19:36 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TFloatFunction {
+ /**
+ * Execute this function with <tt>value</tt>
+ *
+ * @param value an <code>float</code> input
+ * @return an <code>float</code> result
+ */
+ float execute(float value);
+}// TFloatFunction
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatHash.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatHash.java
new file mode 100755
index 0000000..89dd67f
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatHash.java
@@ -0,0 +1,261 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * An open addressed hashing implementation for float primitives.
+ *
+ * Created: Sun Nov 4 08:56:06 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+abstract public class TFloatHash extends TPrimitiveHash
+ implements TFloatHashingStrategy {
+
+ /** the set of floats */
+ protected transient float[] _set;
+
+ /** strategy used to hash values in this collection */
+ protected TFloatHashingStrategy _hashingStrategy;
+
+ /**
+ * Creates a new <code>TFloatHash</code> instance with the default
+ * capacity and load factor.
+ */
+ public TFloatHash() {
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TFloatHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TFloatHash(int initialCapacity) {
+ super(initialCapacity);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TFloatHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ */
+ public TFloatHash(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TFloatHash</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatHash(TFloatHashingStrategy strategy) {
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TFloatHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatHash(int initialCapacity, TFloatHashingStrategy strategy) {
+ super(initialCapacity);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TFloatHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatHash(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TFloatHash h = (TFloatHash)super.clone();
+ h._set = _set.clone();
+ return h;
+ }
+
+ /**
+ * initializes the hash table to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _set = new float[capacity];
+ return capacity;
+ }
+
+ /**
+ * Searches the set for <tt>val</tt>
+ *
+ * @param val an <code>float</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean contains(float val) {
+ return index(val) >= 0;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each element in the set.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the set terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEach(TFloatProcedure procedure) {
+ byte[] states = _states;
+ float[] set = _set;
+ for (int i = set.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(set[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Releases the element currently stored at <tt>index</tt>.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _set[index] = (float)0;
+ super.removeAt(index);
+ }
+
+ /**
+ * Locates the index of <tt>val</tt>.
+ *
+ * @param val an <code>float</code> value
+ * @return the index of <tt>val</tt> or -1 if it isn't in the set.
+ */
+ protected int index(float val) {
+ byte[] states = _states;
+ float[] set = _set;
+ int length = states.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (states[index] != FREE &&
+ (states[index] == REMOVED || set[index] != val)) {
+ // see Knuth, p. 529
+ int probe = 1 + (hash % (length - 2));
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ } while (states[index] != FREE &&
+ (states[index] == REMOVED || set[index] != val));
+ }
+
+ return states[index] == FREE ? -1 : index;
+ }
+
+ /**
+ * Locates the index at which <tt>val</tt> can be inserted. if
+ * there is already a value equal()ing <tt>val</tt> in the set,
+ * returns that value as a negative integer.
+ *
+ * @param val an <code>float</code> value
+ * @return an <code>int</code> value
+ */
+ protected int insertionIndex(float val) {
+ byte[] states = _states;
+ float[] set = _set;
+ int length = states.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (states[index] == FREE) {
+ return index; // empty, all done
+ } else if (states[index] == FULL && set[index] == val) {
+ return -index -1; // already stored
+ } else { // already FULL or REMOVED, must probe
+ // compute the double hash
+ int probe = 1 + (hash % (length - 2));
+ // starting at the natural offset, probe until we find an
+ // offset that isn't full.
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ } while (states[index] == FULL && set[index] != val);
+
+ // if the index we found was removed: continue probing until we
+ // locate a free location or an element which equal()s the
+ // one we have.
+ if (states[index] == REMOVED) {
+ int firstRemoved = index;
+ while (states[index] != FREE &&
+ (states[index] == REMOVED || set[index] != val)) {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ }
+ return states[index] == FULL ? -index -1 : firstRemoved;
+ }
+ // if it's full, the key is already stored
+ return states[index] == FULL ? -index -1 : index;
+ }
+ }
+
+ /**
+ * Default implementation of TFloatHashingStrategy:
+ * delegates hashing to HashFunctions.hash(float).
+ *
+ * @param val the value to hash
+ * @return the hash code.
+ */
+ @Override
+ public final int computeHashCode(float val) {
+ return HashFunctions.hash(val);
+ }
+} // TFloatHash
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatHashSet.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatHashSet.java
new file mode 100755
index 0000000..e39a0e6
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatHashSet.java
@@ -0,0 +1,363 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Arrays;
+
+/**
+ * An open addressed set implementation for float primitives.
+ *
+ * Created: Sat Nov 3 10:38:17 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TFloatHashSet extends TFloatHash {
+
+ /**
+ * Creates a new <code>TFloatHashSet</code> instance with the default
+ * capacity and load factor.
+ */
+ public TFloatHashSet() {
+ }
+
+ /**
+ * Creates a new <code>TFloatHashSet</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TFloatHashSet(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TFloatHashSet</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TFloatHashSet(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TFloatHashSet</code> instance containing the
+ * elements of <tt>array</tt>.
+ *
+ * @param array an array of <code>float</code> primitives
+ */
+ public TFloatHashSet(float[] array) {
+ this(array.length);
+ addAll(array);
+ }
+
+ /**
+ * Creates a new <code>TFloatHash</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatHashSet(TFloatHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TFloatHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatHashSet(int initialCapacity, TFloatHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TFloatHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatHashSet(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * Creates a new <code>TFloatHashSet</code> instance containing the
+ * elements of <tt>array</tt>.
+ *
+ * @param array an array of <code>float</code> primitives
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatHashSet(float[] array, TFloatHashingStrategy strategy) {
+ this(array.length, strategy);
+ addAll(array);
+ }
+
+ /**
+ * @return a TFloatIterator with access to the values in this set
+ */
+ public TFloatIterator iterator() {
+ return new TFloatIterator(this);
+ }
+
+ /**
+ * Inserts a value into the set.
+ *
+ * @param val an <code>float</code> value
+ * @return true if the set was modified by the add operation
+ */
+ public boolean add(float val) {
+ int index = insertionIndex(val);
+
+ if (index < 0) {
+ return false; // already present in set, nothing to add
+ }
+
+ byte previousState = _states[index];
+ _set[index] = val;
+ _states[index] = FULL;
+ postInsertHook(previousState == FREE);
+
+ return true; // yes, we added something
+ }
+
+ /**
+ * Expands the set to accommodate new values.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ float[] oldSet = _set;
+ byte[] oldStates = _states;
+
+ _set = new float[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ float o = oldSet[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * Returns a new array containing the values in the set.
+ *
+ * @return an <code>float[]</code> value
+ */
+ public float[] toArray() {
+ float[] result = new float[size()];
+ float[] set = _set;
+ byte[] states = _states;
+
+ for (int i = states.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ result[j++] = set[i];
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Empties the set.
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ float[] set = _set;
+ byte[] states = _states;
+
+ for (int i = set.length; i-- > 0;) {
+ set[i] = (float)0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Compares this set with another set for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TFloatHashSet)) {
+ return false;
+ }
+ final TFloatHashSet that = (TFloatHashSet)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEach(new TFloatProcedure() {
+ @Override
+ public final boolean execute(float value) {
+ return that.contains(value);
+ }
+ });
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEach(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TFloatProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(float key) {
+ h += _hashingStrategy.computeHashCode(key);
+ return true;
+ }
+ }
+
+ /**
+ * Removes <tt>val</tt> from the set.
+ *
+ * @param val an <code>float</code> value
+ * @return true if the set was modified by the remove operation.
+ */
+ public boolean remove(float val) {
+ int index = index(val);
+ if (index >= 0) {
+ removeAt(index);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Tests the set to determine if all of the elements in
+ * <tt>array</tt> are present.
+ *
+ * @param array an <code>array</code> of float primitives.
+ * @return true if all elements were present in the set.
+ */
+ public boolean containsAll(float[] array) {
+ for (int i = array.length; i-- > 0;) {
+ if (! contains(array[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Adds all of the elements in <tt>array</tt> to the set.
+ *
+ * @param array an <code>array</code> of float primitives.
+ * @return true if the set was modified by the add all operation.
+ */
+ public boolean addAll(float[] array) {
+ boolean changed = false;
+ for (int i = array.length; i-- > 0;) {
+ if (add(array[i])) {
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ /**
+ * Removes all of the elements in <tt>array</tt> from the set.
+ *
+ * @param array an <code>array</code> of float primitives.
+ * @return true if the set was modified by the remove all operation.
+ */
+ public boolean removeAll(float[] array) {
+ boolean changed = false;
+ for (int i = array.length; i-- > 0;) {
+ if (remove(array[i])) {
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ /**
+ * Removes any values in the set which are not contained in
+ * <tt>array</tt>.
+ *
+ * @param array an <code>array</code> of float primitives.
+ * @return true if the set was modified by the retain all operation
+ */
+ public boolean retainAll(float[] array) {
+ Arrays.sort(array);
+ float[] set = _set;
+ byte[] states = _states;
+
+ boolean changed = false;
+ for (int i = set.length; i-- > 0;) {
+ if (states[i] == FULL && Arrays.binarySearch(array,set[i]) < 0) {
+ remove(set[i]);
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEach(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ float val = stream.readFloat();
+ add(val);
+ }
+ }
+} // TFloatHashSet
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatHashingStrategy.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatHashingStrategy.java
new file mode 100755
index 0000000..2daf760
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatHashingStrategy.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.Serializable;
+
+/**
+ * Interface to support pluggable hashing strategies in maps and sets.
+ * Implementors can use this interface to make the trove hashing
+ * algorithms use an optimal strategy when computing hashcodes.
+ *
+ * Created: Sun Nov 4 08:56:06 2001
+ *
+ * @author Eric D. Friedman
+ */
+public interface TFloatHashingStrategy extends Serializable {
+ /**
+ * Computes a hash code for the specified float. Implementors
+ * can use the float's own value or a custom scheme designed to
+ * minimize collisions for a known set of input.
+ *
+ * @param val float for which the hashcode is to be computed
+ * @return the hashCode
+ */
+ public int computeHashCode(float val);
+} // TFloatHashingStrategy
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatIntHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatIntHashMap.java
new file mode 100755
index 0000000..696fce4
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatIntHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for float keys and int values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TFloatIntHashMap extends TFloatHash {
+
+ /** the values of the map */
+ protected transient int[] _values;
+
+ /**
+ * Creates a new <code>TFloatIntHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TFloatIntHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TFloatIntHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TFloatIntHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TFloatIntHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TFloatIntHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TFloatIntHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatIntHashMap(TFloatHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TFloatIntHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatIntHashMap(int initialCapacity, TFloatHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TFloatIntHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatIntHashMap(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TFloatIntHashMap m = (TFloatIntHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TFloatIntIterator with access to this map's keys and values
+ */
+ public TFloatIntIterator iterator() {
+ return new TFloatIntIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new int[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>float</code> value
+ * @param value an <code>int</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public int put(float key, int value) {
+ int previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ float[] oldKeys = _set;
+ int[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new float[newCapacity];
+ _values = new int[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ float o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>float</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public int get(float key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ float[] keys = _set;
+ int[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>float</code> value
+ * @return an <code>int</code> value
+ */
+ public int remove(float key) {
+ int prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TFloatIntHashMap)) {
+ return false;
+ }
+ TFloatIntHashMap that = (TFloatIntHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TFloatIntProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(float key, int value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TFloatIntProcedure {
+ private final TFloatIntHashMap _otherMap;
+
+ EqProcedure(TFloatIntHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(float key, int value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two ints for equality.
+ */
+ private static boolean eq(int v1, int v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public int[] getValues() {
+ int[] vals = new int[size()];
+ int[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public float[] keys() {
+ float[] keys = new float[size()];
+ float[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>int</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(int val) {
+ byte[] states = _states;
+ int[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>float</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(float key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TFloatProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TIntProcedure procedure) {
+ byte[] states = _states;
+ int[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TFloatIntProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TFloatIntProcedure procedure) {
+ byte[] states = _states;
+ float[] keys = _set;
+ int[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TFloatIntProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ float[] keys = _set;
+ int[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TIntFunction</code> value
+ */
+ public void transformValues(TIntFunction function) {
+ byte[] states = _states;
+ int[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(float key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(float key, int amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ float key = stream.readFloat();
+ int val = stream.readInt();
+ put(key, val);
+ }
+ }
+} // TFloatIntHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatIntIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatIntIterator.java
new file mode 100755
index 0000000..406fd26
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatIntIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type float and int.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TFloatIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TFloatIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TFloatIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TFloatIntIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TFloatIntIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TFloatIntHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TFloatIntIterator(TFloatIntHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public float key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public int value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public int setValue(int val) {
+ int old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TFloatIntIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatIntProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatIntProcedure.java
new file mode 100755
index 0000000..a9c4fb4
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatIntProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type float and int.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TFloatIntProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>float</code> value
+ * @param b an <code>int</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(float a, int b);
+}// TFloatIntProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatIterator.java
new file mode 100755
index 0000000..c9bbd2a
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatIterator.java
@@ -0,0 +1,53 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for float collections.
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TFloatIterator extends TPrimitiveIterator {
+ /**
+ * the collection on which the iterator operates
+ */
+ private final TFloatHash _hash;
+
+ /**
+ * Creates a TFloatIterator for the elements in the specified collection.
+ */
+ public TFloatIterator(TFloatHash hash) {
+ super(hash);
+ _hash = hash;
+ }
+
+ /**
+ * Advances the iterator to the next element in the underlying collection
+ * and returns it.
+ *
+ * @return the next float in the collection
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public float next() {
+ moveToNextIndex();
+ return _hash._set[_index];
+ }
+}// TFloatIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatLongHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatLongHashMap.java
new file mode 100755
index 0000000..71be423
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatLongHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for float keys and long values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TFloatLongHashMap extends TFloatHash {
+
+ /** the values of the map */
+ protected transient long[] _values;
+
+ /**
+ * Creates a new <code>TFloatLongHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TFloatLongHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TFloatLongHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TFloatLongHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TFloatLongHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TFloatLongHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TFloatLongHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatLongHashMap(TFloatHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TFloatLongHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatLongHashMap(int initialCapacity, TFloatHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TFloatLongHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatLongHashMap(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TFloatLongHashMap m = (TFloatLongHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TFloatLongIterator with access to this map's keys and values
+ */
+ public TFloatLongIterator iterator() {
+ return new TFloatLongIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new long[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>float</code> value
+ * @param value an <code>long</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public long put(float key, long value) {
+ long previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ float[] oldKeys = _set;
+ long[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new float[newCapacity];
+ _values = new long[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ float o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>float</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public long get(float key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ float[] keys = _set;
+ long[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>float</code> value
+ * @return an <code>long</code> value
+ */
+ public long remove(float key) {
+ long prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TFloatLongHashMap)) {
+ return false;
+ }
+ TFloatLongHashMap that = (TFloatLongHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TFloatLongProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(float key, long value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TFloatLongProcedure {
+ private final TFloatLongHashMap _otherMap;
+
+ EqProcedure(TFloatLongHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(float key, long value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two longs for equality.
+ */
+ private static boolean eq(long v1, long v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public long[] getValues() {
+ long[] vals = new long[size()];
+ long[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public float[] keys() {
+ float[] keys = new float[size()];
+ float[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>long</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(long val) {
+ byte[] states = _states;
+ long[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>float</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(float key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TFloatProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TLongProcedure procedure) {
+ byte[] states = _states;
+ long[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TFloatLongProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TFloatLongProcedure procedure) {
+ byte[] states = _states;
+ float[] keys = _set;
+ long[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TFloatLongProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ float[] keys = _set;
+ long[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TLongFunction</code> value
+ */
+ public void transformValues(TLongFunction function) {
+ byte[] states = _states;
+ long[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(float key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(float key, long amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ float key = stream.readFloat();
+ long val = stream.readLong();
+ put(key, val);
+ }
+ }
+} // TFloatLongHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatLongIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatLongIterator.java
new file mode 100755
index 0000000..94006ba
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatLongIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type float and long.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TFloatLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TFloatLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TFloatLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TFloatLongIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TFloatLongIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TFloatLongHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TFloatLongIterator(TFloatLongHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public float key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public long value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public long setValue(long val) {
+ long old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TFloatLongIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatLongProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatLongProcedure.java
new file mode 100755
index 0000000..5ba91c9
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatLongProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type float and long.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TFloatLongProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>float</code> value
+ * @param b an <code>long</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(float a, long b);
+}// TFloatLongProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatObjectHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatObjectHashMap.java
new file mode 100755
index 0000000..a0152cc
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatObjectHashMap.java
@@ -0,0 +1,668 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for float keys and Object values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TFloatObjectHashMap<V> extends THash implements TFloatHashingStrategy {
+
+ /** the values of the map */
+ protected transient V[] _values;
+
+ /** the set of floats */
+ protected transient float[] _set;
+
+ /** strategy used to hash values in this collection */
+ protected final TFloatHashingStrategy _hashingStrategy;
+
+ /**
+ * Creates a new <code>TFloatObjectHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TFloatObjectHashMap() {
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TFloatObjectHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TFloatObjectHashMap(int initialCapacity) {
+ super(initialCapacity);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TFloatObjectHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TFloatObjectHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TFloatObjectHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatObjectHashMap(TFloatHashingStrategy strategy) {
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TFloatObjectHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatObjectHashMap(int initialCapacity, TFloatHashingStrategy strategy) {
+ super(initialCapacity);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TFloatObjectHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TFloatObjectHashMap(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public TFloatObjectHashMap<V> clone() {
+ TFloatObjectHashMap<V> m = (TFloatObjectHashMap<V>)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TFloatObjectIterator with access to this map's keys and values
+ */
+ public TFloatObjectIterator<V> iterator() {
+ return new TFloatObjectIterator<V>(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = (V[]) new Object[capacity];
+ _set = new float[capacity];
+
+ return capacity;
+ }
+
+ /**
+ * Searches the set for <tt>val</tt>
+ *
+ * @param val an <code>float</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean contains(float val) {
+ return index(val) >= 0;
+ }
+
+
+ /**
+ * Returns the capacity of the hash table. This is the true
+ * physical capacity, without adjusting for the load factor.
+ *
+ * @return the physical capacity of the hash table.
+ */
+ @Override
+ protected int capacity() {
+ return _values.length;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each element in the set.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return false if the loop over the set terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEach(TFloatProcedure procedure) {
+ float[] set = _set;
+ Object[] values = _values;
+ for (int i = set.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(set[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>float</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public V put(float key, V value) {
+ boolean wasFree = false;
+ V previous = null;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = unwrapNull(_values[index]);
+ isNewMapping = false;
+ }
+ else {
+ wasFree = isFree(_values, index);
+ }
+ _set[index] = key;
+ _values[index] = wrapNull(value);
+ if (isNewMapping) {
+ postInsertHook(wasFree);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ float[] oldKeys = _set;
+ V[] oldVals = _values;
+
+ _set = new float[newCapacity];
+ _values = (V[]) new Object[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(isFull(oldVals, i)) {
+ float o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>float</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public V get(float key) {
+ int index = index(key);
+ return index < 0 ? null : unwrapNull(_values[index]);
+ }
+
+ private static <V> V unwrapNull(V value) {
+ return value == TObjectHash.NULL ? null : value;
+ }
+ private static <V> V wrapNull(V value) {
+ return value == null ? (V)TObjectHash.NULL : value;
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ float[] keys = _set;
+ Object[] values = _values;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = (float)0;
+ values[i] = null;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>float</code> value
+ * @return an <code>Object</code> value
+ */
+ public V remove(float key) {
+ V prev = null;
+ int index = index(key);
+ if (index >= 0) {
+ prev = unwrapNull(_values[index]);
+ removeAt(index); // clear key,set; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Locates the index of <tt>val</tt>.
+ *
+ * @param val an <code>float</code> value
+ * @return the index of <tt>val</tt> or -1 if it isn't in the set.
+ */
+ protected int index(float val) {
+ float[] set = _set;
+ Object[] values = _values;
+ int length = set.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (!isFree(values, index) &&
+ (isRemoved(values, index) || set[index] != val)) {
+ // see Knuth, p. 529
+ int probe = 1 + (hash % (length - 2));
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ } while (!isFree(values, index) &&
+ (isRemoved(values, index) || set[index] != val));
+ }
+
+ return isFree(values, index) ? -1 : index;
+ }
+
+ /**
+ * Locates the index at which <tt>val</tt> can be inserted. if
+ * there is already a value equal()ing <tt>val</tt> in the set,
+ * returns that value as a negative integer.
+ *
+ * @param val an <code>float</code> value
+ * @return an <code>int</code> value
+ */
+ protected int insertionIndex(float val) {
+ Object[] values = _values;
+ float[] set = _set;
+ int length = set.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (isFree(values, index)) {
+ return index; // empty, all done
+ }
+ if (isFull(values, index) && set[index] == val) {
+ return -index -1; // already stored
+ }
+
+ // already FULL or REMOVED, must probe
+ // compute the double hash
+ int probe = 1 + (hash % (length - 2));
+ // starting at the natural offset, probe until we find an
+ // offset that isn't full.
+
+ // keep track of the first removed cell. it's the natural candidate for re-insertion
+ int firstRemoved = isRemoved(values, index) ? index : -1;
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ if (firstRemoved == -1 && isRemoved(values, index)) {
+ firstRemoved = index;
+ }
+ }
+ while (isFull(values, index) && set[index] != val);
+
+ // if the index we found was removed: continue probing until we
+ // locate a free location or an element which equal()s the
+ // one we have.
+ if (isRemoved(values, index)) {
+ while (!isFree(values, index) &&
+ (isRemoved(values, index) || set[index] != val)) {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ }
+ }
+ // if it's full, the key is already stored
+ if (isFull(values, index)) {
+ return -index -1;
+ }
+
+ return firstRemoved == -1 ? index : firstRemoved;
+ }
+
+ static boolean isFull(Object[] values, int index) {
+ Object value = values[index];
+ return value != null && value != TObjectHash.REMOVED;
+ }
+
+ private static boolean isRemoved(Object[] values, int index) {
+ return values[index] == TObjectHash.REMOVED;
+ }
+
+ private static boolean isFree(Object[] values, int index) {
+ return values[index] == null;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TFloatObjectHashMap)) {
+ return false;
+ }
+ TFloatObjectHashMap that = (TFloatObjectHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure<V>(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TFloatObjectProcedure<V> {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(float key, V value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure<V> implements TFloatObjectProcedure<V> {
+ private final TFloatObjectHashMap<V> _otherMap;
+
+ EqProcedure(TFloatObjectHashMap<V> otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(float key, V value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two objects for equality.
+ */
+ private static boolean eq(Object o1, Object o2) {
+ return o1 == o2 || o1 != null && o1.equals(o2);
+ }
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = (V)TObjectHash.REMOVED;
+ super.removeAt(index); // clear key, set; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a value <code>array</code>
+ */
+ public Object[] getValues() {
+ Object[] vals = new Object[size()];
+ V[] values = _values;
+
+ for (int i = values.length, j = 0; i-- > 0;) {
+ if (isFull(values, i)) {
+ vals[j++] = unwrapNull(values[i]);
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public float[] keys() {
+ float[] keys = new float[size()];
+ float[] k = _set;
+ Object[] values = _values;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (isFull(values, i)) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(V val) {
+ V[] values = _values;
+
+ // special case null values so that we don't have to
+ // perform null checks before every call to equals()
+ if (null == val) {
+ for (int i = values.length; i-- > 0;) {
+ if (TObjectHash.NULL == values[i]) {
+ return true;
+ }
+ }
+ }
+ else {
+ for (int i = values.length; i-- > 0;) {
+ V value = unwrapNull(values[i]);
+ if (isFull(values, i) && (val == value || val.equals(value))) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>float</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(float key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TFloatProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TObjectProcedure<V> procedure) {
+ V[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(unwrapNull(values[i]))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TOFloatObjectProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TFloatObjectProcedure<V> procedure) {
+ float[] keys = _set;
+ V[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(keys[i],unwrapNull(values[i]))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TFloatObjectProcedure<V> procedure) {
+ boolean modified = false;
+ float[] keys = _set;
+ V[] values = _values;
+ stopCompactingOnRemove();
+ try {
+ for (int i = keys.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(keys[i],unwrapNull(values[i]))) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ }
+ finally {
+ startCompactingOnRemove(modified);
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TObjectFunction</code> value
+ */
+ public void transformValues(TObjectFunction<V,V> function) {
+ V[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (isFull(values, i)) {
+ values[i] = wrapNull(function.execute(unwrapNull(values[i])));
+ }
+ }
+ }
+
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ float key = stream.readFloat();
+ V val = (V) stream.readObject();
+ put(key, val);
+ }
+ }
+
+ /**
+ * Default implementation of TFloatHashingStrategy:
+ * delegates hashing to HashFunctions.hash(float).
+ *
+ * @param val the value to hash
+ * @return the hashcode.
+ */
+ @Override
+ public final int computeHashCode(float val) {
+ return HashFunctions.hash(val);
+ }
+
+} // TFloatObjectHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatObjectIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatObjectIterator.java
new file mode 100755
index 0000000..0494790
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatObjectIterator.java
@@ -0,0 +1,168 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.util.ConcurrentModificationException;
+
+/**
+ * Iterator for maps of type float and Object.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TFloatObjectIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TFloatObjectIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TFloatObjectIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TFloatObjectIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+public class TFloatObjectIterator <V> extends TIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TFloatObjectHashMap<V> _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TFloatObjectIterator(TFloatObjectHashMap<V> map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Returns the index of the next value in the data structure
+ * or a negative value if the iterator is exhausted.
+ *
+ * @return an <code>int</code> value
+ * @exception ConcurrentModificationException if the underlying collection's
+ * size has been modified since the iterator was created.
+ */
+ @Override
+ protected final int nextIndex() {
+ if (_expectedSize != _map.size()) {
+ throw new ConcurrentModificationException();
+ }
+
+ Object[] values = _map._values;
+ int i = _index;
+ while (i-- > 0 && !TFloatObjectHashMap.isFull(values, i));
+ return i;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public float key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public V value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public V setValue(V val) {
+ V old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TFloatObjectIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatObjectProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatObjectProcedure.java
new file mode 100755
index 0000000..f970840
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatObjectProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type float and Object.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TFloatObjectProcedure<V> {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>float</code> value
+ * @param b an <code>Object</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(float a, V b);
+}// TFloatObjectProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatProcedure.java
new file mode 100755
index 0000000..7226564
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TFloatProcedure.java
@@ -0,0 +1,40 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures with one float parameter.
+ *
+ * Created: Mon Nov 5 21:45:49 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TFloatProcedure {
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param value a value of type <code>float</code>
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(float value);
+}// TFloatProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/THash.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/THash.java
new file mode 100755
index 0000000..708178c
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/THash.java
@@ -0,0 +1,291 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+/**
+ * Base class for hashtables that use open addressing to resolve
+ * collisions.
+ *
+ * Created: Wed Nov 28 21:11:16 2001
+ *
+ * @author Eric D. Friedman
+ * @version $Id: THash.java,v 1.5 2004/09/24 09:11:15 cdr Exp $
+ */
+
+public abstract class THash implements Cloneable {
+ /** the current number of occupied slots in the hash. */
+ protected transient int _size;
+
+ /** the current number of free slots in the hash. */
+ protected transient int _free;
+
+ /**
+ * Number of entries marked REMOVED (by either TObjectHash or TPrimitiveHash)
+ */
+ protected transient int _deadkeys;
+
+ /**
+ * the load above which rehashing occurs.
+ */
+ protected static final float DEFAULT_LOAD_FACTOR = 0.8f;
+
+ /** 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.
+ */
+ protected static final int DEFAULT_INITIAL_CAPACITY = 4;
+
+ /** 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.
+ */
+ protected final float _loadFactor;
+
+ /**
+ * The maximum number of elements allowed without allocating more
+ * space.
+ */
+ protected int _maxSize;
+
+ /**
+ * Creates a new <code>THash</code> instance with the default
+ * capacity and load factor.
+ */
+ public THash() {
+ this(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR);
+ }
+
+ /**
+ * Creates a new <code>THash</code> instance with a prime capacity
+ * at or near the specified capacity and with the default load
+ * factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public THash(int initialCapacity) {
+ this(initialCapacity, DEFAULT_LOAD_FACTOR);
+ }
+
+ /**
+ * Creates a new <code>THash</code> instance with a prime capacity
+ * at or near the minimum needed to hold <tt>initialCapacity</tt>
+ * elements with load factor <tt>loadFactor</tt> without triggering
+ * a rehash.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public THash(int initialCapacity, float loadFactor) {
+ super();
+ _loadFactor = loadFactor;
+ setUp((int) (initialCapacity / loadFactor) + 1);
+ }
+
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException cnse) {
+ return null; // it's supported
+ }
+ }
+
+ /**
+ * Tells whether this set is currently holding any elements.
+ *
+ * @return a <code>boolean</code> value
+ */
+ public boolean isEmpty() {
+ return 0 == _size;
+ }
+
+ /**
+ * Returns the number of distinct elements in this collection.
+ *
+ * @return an <code>int</code> value
+ */
+ public int size() {
+ return _size;
+ }
+
+ /**
+ * @return the current physical capacity of the hash table.
+ */
+ protected abstract int capacity();
+
+ /**
+ * Ensure that this hashtable has sufficient capacity to hold
+ * <tt>desiredCapacity<tt> <b>additional</b> elements without
+ * requiring a rehash. This is a tuning method you can call
+ * before doing a large insert.
+ *
+ * @param desiredCapacity an <code>int</code> value
+ */
+ public void ensureCapacity(int desiredCapacity) {
+ if (desiredCapacity > (_maxSize - size())) {
+ rehash(PrimeFinder.nextPrime((int) (desiredCapacity + size() /
+ _loadFactor) + 2));
+ computeMaxSize(capacity());
+ }
+ }
+
+ /**
+ * 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 <tt>remove</tt>
+ * 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:
+ *
+ * <ol>
+ * <li> You'll free memory allocated to the table but no
+ * longer needed because of the remove()s.</li>
+ *
+ * <li> You'll get better query/insert/iterator performance
+ * because there won't be any <tt>REMOVED</tt> slots to skip
+ * over when probing for indices in the table.</li>
+ * </ol>
+ */
+ public void compact() {
+ // need at least one free spot for open addressing
+ rehash(PrimeFinder.nextPrime((int) (size() / _loadFactor) + 2));
+ computeMaxSize(capacity());
+ }
+
+ /**
+ * This simply calls {@link #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
+ * <tt>compact</tt>) as the load factor may require capacity above
+ * and beyond the size of this collection.
+ *
+ * @see #compact
+ */
+ public final void trimToSize() {
+ compact();
+ }
+
+ /**
+ * Delete the record at <tt>index</tt>. Reduces the size of the
+ * collection by one.
+ *
+ * @param index an <code>int</code> value
+ */
+ protected void removeAt(int index) {
+ _size--;
+ _deadkeys++;
+
+ compactIfNecessary();
+ }
+
+ private void compactIfNecessary() {
+ if (_deadkeys > _size && capacity() > 42) {
+ // Compact if more than 50% of all keys are dead. Also, don't trash small maps
+ compact();
+ }
+ }
+
+ public final void stopCompactingOnRemove() {
+ if (_deadkeys < 0) {
+ throw new IllegalStateException("Unpaired stop/startCompactingOnRemove");
+ }
+
+ _deadkeys -= capacity();
+ }
+
+ public final void startCompactingOnRemove(boolean compact) {
+ if (_deadkeys >= 0) {
+ throw new IllegalStateException("Unpaired stop/startCompactingOnRemove");
+ }
+ _deadkeys += capacity();
+
+ if (compact) {
+ compactIfNecessary();
+ }
+ }
+
+ /**
+ * Empties the collection.
+ */
+ public void clear() {
+ _size = 0;
+ _free = capacity();
+ _deadkeys = 0;
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ protected int setUp(int initialCapacity) {
+ int capacity = PrimeFinder.nextPrime(initialCapacity);
+ computeMaxSize(capacity);
+ return capacity;
+ }
+
+ /**
+ * Rehashes the set.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ protected abstract void rehash(int newCapacity);
+
+ /**
+ * Computes the values of maxSize. There will always be at least
+ * one free slot required.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ private void computeMaxSize(int capacity) {
+ // need at least one free slot for open addressing
+ _maxSize = Math.min(capacity - 1, (int) (capacity * _loadFactor));
+ _free = capacity - _size; // reset the free element count
+ _deadkeys = 0;
+ }
+
+ /**
+ * After an insert, this hook is called to adjust the size/free
+ * values of the set and to perform rehashing if necessary.
+ */
+ protected final void postInsertHook(boolean usedFreeSlot) {
+ if (usedFreeSlot) {
+ _free--;
+ }
+ else {
+ _deadkeys--;
+ }
+
+ // rehash whenever we exhaust the available space in the table
+ if (++_size > _maxSize || _free == 0) {
+ rehash(PrimeFinder.nextPrime(calculateGrownCapacity()));
+ computeMaxSize(capacity());
+ }
+ }
+
+ protected int calculateGrownCapacity() {
+ return capacity() << 1;
+ }
+}// THash
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/THashIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/THashIterator.java
new file mode 100755
index 0000000..e798078
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/THashIterator.java
@@ -0,0 +1,102 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+import java.util.ConcurrentModificationException;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * Implements all iterator functions for the hashed object set.
+ * Subclasses may override objectAtIndex to vary the object
+ * returned by calls to next() (e.g. for values, and Map.Entry
+ * objects).
+ *
+ * <p> Note that iteration is fastest if you forego the calls to
+ * <tt>hasNext</tt> in favor of checking the size of the structure
+ * yourself and then call next() that many times:
+ *
+ * <pre>
+ * Iterator i = collection.iterator();
+ * for (int size = collection.size(); size-- > 0;) {
+ * Object o = i.next();
+ * }
+ * </pre>
+ *
+ * <p>You may, of course, use the hasNext(), next() idiom too if
+ * you aren't in a performance critical spot.</p>
+ *
+ */
+abstract class THashIterator<V> extends TIterator implements Iterator<V> {
+ protected final TObjectHash _hash;
+
+ /**
+ * Create an instance of THashIterator over the values of the TObjectHash
+ */
+ public THashIterator(TObjectHash hash) {
+ super(hash);
+ _hash = hash;
+ }
+
+ /**
+ * Moves the iterator to the next Object and returns it.
+ *
+ * @return an <code>Object</code> value
+ * @exception ConcurrentModificationException if the structure
+ * was changed using a method that isn't on this iterator.
+ * @exception NoSuchElementException if this is called on an
+ * exhausted iterator.
+ */
+ @Override
+ public V next() {
+ moveToNextIndex();
+ return objectAtIndex(_index);
+ }
+
+ /**
+ * Returns the index of the next value in the data structure
+ * or a negative value if the iterator is exhausted.
+ *
+ * @return an <code>int</code> value
+ * @exception ConcurrentModificationException if the underlying
+ * collection's size has been modified since the iterator was
+ * created.
+ */
+ @Override
+ protected final int nextIndex() {
+ if (_expectedSize != _hash.size()) {
+ throw new ConcurrentModificationException();
+ }
+
+ Object[] set = _hash._set;
+ int i = _index;
+ while (i-- > 0 && (set[i] == null || set[i] == TObjectHash.REMOVED)) ;
+ return i;
+ }
+
+ /**
+ * Returns the object at the specified index. Subclasses should
+ * implement this to return the appropriate object for the given
+ * index.
+ *
+ * @param index the index of the value to return.
+ * @return an <code>Object</code> value
+ */
+ protected abstract V objectAtIndex(int index);
+} // THashIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/THashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/THashMap.java
new file mode 100755
index 0000000..8b5a72c
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/THashMap.java
@@ -0,0 +1,800 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.Array;
+import java.util.*;
+
+/**
+ * An implementation of the Map interface which uses an open addressed
+ * hash table to store its contents.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class THashMap<K,V> extends TObjectHash<K> implements Map<K,V> {
+
+ /** the values of the map */
+ protected transient V[] _values;
+
+ /**
+ * Creates a new <code>THashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public THashMap() {
+ super();
+ }
+
+ /**
+ * Creates a new <code>THashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare objects.
+ */
+ public THashMap(TObjectHashingStrategy<K> strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>THashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public THashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>THashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare objects.
+ */
+ public THashMap(int initialCapacity, TObjectHashingStrategy<K> strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>THashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public THashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>THashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ * @param strategy used to compute hash codes and to compare objects.
+ */
+ public THashMap(int initialCapacity, float loadFactor, TObjectHashingStrategy<K> strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * Creates a new <code>THashMap</code> instance which contains the
+ * key/value pairs in <tt>map</tt>.
+ *
+ * @param map a <code>Map</code> value
+ */
+ public THashMap(Map<K,V> map) {
+ this(map.size());
+ putAll(map);
+ }
+
+ /**
+ * Creates a new <code>THashMap</code> instance which contains the
+ * key/value pairs in <tt>map</tt>.
+ *
+ * @param map a <code>Map</code> value
+ * @param strategy used to compute hash codes and to compare objects.
+ */
+ public THashMap(Map<K,V> map, TObjectHashingStrategy<K> strategy) {
+ this(map.size(), strategy);
+ putAll(map);
+ }
+
+ /**
+ * @return a shallow clone of this collection
+ */
+ @Override
+ public THashMap<K,V> clone() {
+ THashMap<K,V> m = (THashMap<K,V>)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * initialize the value array of the map.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return an <code>int</code> value
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = (V[]) new Object[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ @Override
+ public V put(K key, V value) {
+ if (null == key) {
+ throw new NullPointerException("null keys not supported");
+ }
+ V previous = null;
+ int index = insertionIndex(key);
+ boolean alreadyStored = index < 0;
+ if (alreadyStored) {
+ index = -index -1;
+ previous = _values[index];
+ }
+ Object oldKey = _set[index];
+ _set[index] = key;
+ _values[index] = value;
+ if (!alreadyStored) {
+ postInsertHook(oldKey == null);
+ }
+
+ return previous;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof Map)) {
+ return false;
+ }
+ Map<K, V> that = (Map<K, V>)other;
+ if (that.size() != size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure<K,V>(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TObjectObjectProcedure<K,V> {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(K key, V value) {
+ h += _hashingStrategy.computeHashCode(key) ^ (value == null ? 0 : value.hashCode());
+ return true;
+ }
+ }
+
+ private static final class EqProcedure<K,V> implements TObjectObjectProcedure<K,V> {
+ private final Map<K,V> _otherMap;
+
+ EqProcedure(Map<K,V> otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(K key, V value) {
+ V oValue = _otherMap.get(key);
+ return oValue == value || (oValue != null && oValue.equals(value));
+ }
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TObjectProcedure<K> procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TObjectProcedure<V> procedure) {
+ V[] values = _values;
+ Object[] set = _set;
+ for (int i = values.length; i-- > 0;) {
+ if (set[i] != null
+ && set[i] != REMOVED
+ && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TObjectObjectProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TObjectObjectProcedure<K,V> procedure) {
+ Object[] keys = _set;
+ V[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (keys[i] != null
+ && keys[i] != REMOVED
+ && ! procedure.execute((K) keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TObjectObjectProcedure<K,V> procedure) {
+ Object[] keys = _set;
+ V[] values = _values;
+ stopCompactingOnRemove();
+ boolean modified = false;
+ try {
+ for (int i = keys.length; i-- > 0;) {
+ if (keys[i] != null
+ && keys[i] != REMOVED
+ && ! procedure.execute((K) keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ }
+ finally {
+ startCompactingOnRemove(modified);
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TObjectFunction</code> value
+ */
+ public void transformValues(TObjectFunction<V,V> function) {
+ V[] values = _values;
+ Object[] set = _set;
+ for (int i = values.length; i-- > 0;) {
+ if (set[i] != null && set[i] != REMOVED) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ Object[] oldKeys = _set;
+ V[] oldVals = _values;
+
+ _set = new Object[newCapacity];
+ _values = (V[]) new Object[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldKeys[i] != null && oldKeys[i] != REMOVED) {
+ Object o = oldKeys[i];
+ int index = insertionIndex((K) o);
+ if (index < 0) {
+ throwObjectContractViolation(_set[-index -1], o);
+ }
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ @Override
+ public V get(Object key) {
+ int index = index((K) key);
+ return index < 0 ? null : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ // optimization
+ if (size() != 0) {
+ super.clear();
+ Object[] keys = _set;
+ V[] values = _values;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = null;
+ values[i] = null;
+ }
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return an <code>Object</code> value
+ */
+ @Override
+ public V remove(Object key) {
+ V prev = null;
+ int index = index((K) key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = null;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns a view on the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ @Override
+ public Collection<V> values() {
+ return new ValueView();
+ }
+
+ /**
+ * returns a Set view on the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<K> keySet() {
+ return new KeyView();
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<K,V>> entrySet() {
+ return new EntryView();
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ Object[] set = _set;
+ V[] vals = _values;
+
+ // special case null values so that we don't have to
+ // perform null checks before every call to equals()
+ if (null == val) {
+ for (int i = vals.length; i-- > 0;) {
+ if (set[i] != null && set[i] != REMOVED &&
+ val == vals[i]) {
+ return true;
+ }
+ }
+ } else {
+ for (int i = vals.length; i-- > 0;) {
+ if (set[i] != null && set[i] != REMOVED &&
+ (val == vals[i] || val.equals(vals[i]))) {
+ return true;
+ }
+ }
+ } // end of else
+ return false;
+ }
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return contains(key);
+ }
+
+ /**
+ * copies the key/value mappings in <tt>map</tt> into this map.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends K, ? extends V> map) {
+ ensureCapacity(map.size());
+ // could optimize this for cases when map instanceof THashMap
+ for (Map.Entry<? extends K, ? extends V> e : map.entrySet()) {
+ put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * a view onto the values of the map.
+ *
+ */
+ protected class ValueView extends MapBackedView<V> {
+ @Override
+ public Iterator<V> iterator() {
+ return new THashIterator<V>(THashMap.this) {
+ @Override
+ protected V objectAtIndex(int index) {
+ return _values[index];
+ }
+ };
+ }
+
+ @Override
+ public boolean containsElement(V value) {
+ return containsValue(value);
+ }
+
+ @Override
+ public boolean removeElement(V value) {
+ boolean changed = false;
+ Object[] values = _values;
+ Object[] set = _set;
+
+ for (int i = values.length; i-- > 0;) {
+ if (set[i] != null && set[i] != REMOVED &&
+ value == values[i] ||
+ (null != values[i] && values[i].equals(value))) {
+ removeAt(i);
+ changed = true;
+ }
+ }
+ return changed;
+ }
+ }
+
+ /**
+ * a view onto the entries of the map.
+ *
+ */
+ protected class EntryView extends MapBackedView<Map.Entry<K,V>> {
+ EntryView() {
+ }
+
+ private final class EntryIterator extends THashIterator<Map.Entry<K,V>> {
+ EntryIterator(THashMap<K,V> map) {
+ super(map);
+ }
+
+ @Override
+ public Entry objectAtIndex(final int index) {
+ return new Entry((K) _set[index], _values[index], index);
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<K,V>> iterator() {
+ return new EntryIterator(THashMap.this);
+ }
+
+ @Override
+ public boolean removeElement(Map.Entry<K,V> entry) {
+ // have to effectively reimplement Map.remove here
+ // because we need to return true/false depending on
+ // whether the removal took place. Since the Entry's
+ // value can be null, this means that we can't rely
+ // on the value of the object returned by Map.remove()
+ // to determine whether a deletion actually happened.
+ //
+ // Note also that the deletion is only legal if
+ // both the key and the value match.
+
+ K key = keyForEntry(entry);
+ int index = index(key);
+ if (index >= 0) {
+ Object val = valueForEntry(entry);
+ if (val == _values[index] ||
+ (null != val && val.equals(_values[index]))) {
+ removeAt(index); // clear key,state; adjust size
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean containsElement(Map.Entry<K,V> entry) {
+ Object val = get(keyForEntry(entry));
+ Object entryValue = entry.getValue();
+ return entryValue == val ||
+ (null != val && val.equals(entryValue));
+ }
+
+ protected V valueForEntry(Map.Entry<K,V> entry) {
+ return entry.getValue();
+ }
+
+ protected K keyForEntry(Map.Entry<K,V> entry) {
+ return entry.getKey();
+ }
+ }
+
+ private abstract class MapBackedView<E> implements Set<E> {
+ MapBackedView() {
+ }
+
+ @Override
+ public abstract Iterator<E> iterator();
+
+ public abstract boolean removeElement(E key);
+
+ public abstract boolean containsElement(E key);
+
+ @Override
+ public boolean contains(Object key) {
+ return containsElement((E) key);
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ return removeElement((E) o);
+ }
+
+ @Override
+ public boolean containsAll(Collection<?> collection) {
+ for (Object element : collection) {
+ if (!contains(element)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> collection) {
+ boolean changed = false;
+ for (Object element : collection) {
+ if (remove(element)) {
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ @Override
+ public void clear() {
+ THashMap.this.clear();
+ }
+
+ @Override
+ public boolean add(E obj) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int size() {
+ return THashMap.this.size();
+ }
+
+ @Override
+ public Object[] toArray() {
+ Object[] result = new Object[size()];
+ Iterator e = iterator();
+ for (int i = 0; e.hasNext(); i++) {
+ result[i] = e.next();
+ }
+ return result;
+ }
+
+ @Override
+ public <T> T[] toArray(T[] a){
+ int size = size();
+ if (a.length < size) {
+ a = (T[]) Array.newInstance(a.getClass().getComponentType(), size);
+ }
+
+ Iterator<E> it = iterator();
+ Object[] result = a;
+ for (int i=0; i<size; i++) {
+ result[i] = it.next();
+ }
+
+ if (a.length > size) {
+ a[size] = null;
+ }
+
+ return a;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return THashMap.this.isEmpty();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends E> collection) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> collection) {
+ boolean changed = false;
+ Iterator i = iterator();
+ while (i.hasNext()) {
+ if (! collection.contains(i.next())) {
+ i.remove();
+ changed = true;
+ }
+ }
+ return changed;
+ }
+ }
+
+ /**
+ * a view onto the keys of the map.
+ */
+ protected class KeyView extends MapBackedView<K> {
+ KeyView() {
+ }
+
+ @Override
+ public Iterator<K> iterator() {
+ return new TObjectHashIterator<K>(THashMap.this);
+ }
+
+ @Override
+ public boolean removeElement(K key) {
+ return null != THashMap.this.remove(key);
+ }
+
+ @Override
+ public boolean containsElement(K key) {
+ return THashMap.this.contains(key);
+ }
+ }
+
+ final class Entry implements Map.Entry<K,V> {
+ private final K key;
+ private V val;
+ private final int index;
+
+ Entry(final K key, V value, final int index) {
+ this.key = key;
+ val = value;
+ this.index = index;
+ }
+
+ @Override
+ public K getKey() {
+ return key;
+ }
+
+ @Override
+ public V getValue() {
+ return val;
+ }
+
+ @Override
+ public V setValue(V o) {
+ if (_values[index] != val) {
+ throw new ConcurrentModificationException();
+ }
+ _values[index] = o;
+ V prev = val; // need to return previous value
+ val = o; // update this entry's value, in case
+ // setValue is called again
+ return prev;
+ }
+ }
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ K key = (K) stream.readObject();
+ V val = (V) stream.readObject();
+ put(key, val);
+ }
+ }
+} // THashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/THashSet.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/THashSet.java
new file mode 100755
index 0000000..e7e14c5
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/THashSet.java
@@ -0,0 +1,392 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * An implementation of the <tt>Set</tt> interface that uses an
+ * open-addressed hash table to store its contents.
+ *
+ * Created: Sat Nov 3 10:38:17 2001
+ *
+ * @author Eric D. Friedman
+ * @version $Id: THashSet.java,v 1.5 2004/09/24 09:11:15 cdr Exp $
+ */
+
+public class THashSet<E> extends TObjectHash<E> implements Set<E> {
+
+ /**
+ * Creates a new <code>THashSet</code> instance with the default
+ * capacity and load factor.
+ */
+ public THashSet() {
+ super();
+ }
+
+ /**
+ * Creates a new <code>THashSet</code> instance with the default
+ * capacity and load factor.
+ *
+ * @param strategy used to compute hash codes and to compare objects.
+ */
+ public THashSet(TObjectHashingStrategy<E> strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>THashSet</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public THashSet(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>THashSet</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare objects.
+ */
+ public THashSet(int initialCapacity, TObjectHashingStrategy<E> strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>THashSet</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public THashSet(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>THashSet</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ * @param strategy used to compute hash codes and to compare objects.
+ */
+ public THashSet(int initialCapacity, float loadFactor, TObjectHashingStrategy<E> strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * Creates a new <code>THashSet</code> instance containing the
+ * elements of <tt>collection</tt>.
+ *
+ * @param collection a <code>Collection</code> value
+ */
+ public THashSet(Collection<? extends E> collection) {
+ this(collection.size());
+ addAll(collection);
+ }
+
+ /**
+ * Creates a new <code>THashSet</code> instance containing the
+ * elements of <tt>collection</tt>.
+ *
+ * @param collection a <code>Collection</code> value
+ * @param strategy used to compute hash codes and to compare objects.
+ */
+ public THashSet(Collection<? extends E> collection, TObjectHashingStrategy<E> strategy) {
+ this(collection.size(), strategy);
+ addAll(collection);
+ }
+
+ /**
+ * Inserts a value into the set.
+ *
+ * @param obj an <code>Object</code> value
+ * @return true if the set was modified by the add operation
+ */
+ @Override
+ public boolean add(E obj) {
+ int index = insertionIndex(obj);
+
+ if (index < 0) {
+ return false; // already present in set, nothing to add
+ }
+
+ Object old = _set[index];
+ _set[index] = obj;
+
+ postInsertHook(old == null);
+ return true; // yes, we added something
+ }
+
+ public boolean equals(Object other) {
+ if (! (other instanceof Set)) {
+ return false;
+ }
+ Set that = (Set)other;
+ if (that.size() != size()) {
+ return false;
+ }
+ return containsAll(that);
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEach(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TObjectProcedure<E> {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(E key) {
+ h += _hashingStrategy.computeHashCode(key);
+ return true;
+ }
+ }
+
+ /**
+ * Expands the set to accomodate new values.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ Object[] oldSet = _set;
+
+ _set = new Object[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldSet[i] != null && oldSet[i] != REMOVED) {
+ E o = (E) oldSet[i];
+ int index = insertionIndex(o);
+ if (index < 0) { // everyone pays for this because some people can't RTFM
+ throwObjectContractViolation(_set[(-index -1)], o);
+ }
+ _set[index] = o;
+ }
+ }
+ }
+
+ /**
+ * Returns a new array containing the objects in the set.
+ *
+ * @return an <code>Object[]</code> value
+ */
+ @Override
+ public Object[] toArray() {
+ Object[] result = new Object[size()];
+ forEach(new ToObjectArrayProcedure(result));
+ return result;
+ }
+
+ /**
+ * Returns a typed array of the objects in the set.
+ *
+ * @param a an <code>Object[]</code> value
+ * @return an <code>Object[]</code> value
+ */
+ @Override
+ public <T> T[] toArray(T[] a) {
+ int size = size();
+ if (a.length < size)
+ a = (T[]) Array.newInstance(a.getClass().getComponentType(), size);
+
+ Object[] result = a;
+
+ Iterator it = iterator();
+ for (int i=0; i<size; i++) {
+ result[i] = it.next();
+ }
+
+ if (a.length > size) {
+ a[size] = null;
+ }
+
+ return a;
+ }
+
+ /**
+ * Empties the set.
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ Object[] set = _set;
+
+ for (int i = set.length; i-- > 0;) {
+ set[i] = null;
+ }
+ }
+
+ /**
+ * Removes <tt>obj</tt> from the set.
+ *
+ * @param obj an <code>Object</code> value
+ * @return true if the set was modified by the remove operation.
+ */
+ @Override
+ public boolean remove(Object obj) {
+ int index = index((E) obj);
+ if (index >= 0) {
+ removeAt(index);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Creates an iterator over the values of the set. The iterator
+ * supports element deletion.
+ *
+ * @return an <code>Iterator</code> value
+ */
+ @Override
+ public Iterator<E> iterator() {
+ return new TObjectHashIterator<E>(this);
+ }
+
+ /**
+ * Tests the set to determine if all of the elements in
+ * <tt>collection</tt> are present.
+ *
+ * @param collection a <code>Collection</code> value
+ * @return true if all elements were present in the set.
+ */
+ @Override
+ public boolean containsAll(Collection<?> collection) {
+ for (Object element : collection) {
+ if (!contains(element)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Adds all of the elements in <tt>collection</tt> to the set.
+ *
+ * @param collection a <code>Collection</code> value
+ * @return true if the set was modified by the add all operation.
+ */
+ @Override
+ public boolean addAll(Collection<? extends E> collection) {
+ int size = collection.size();
+
+ ensureCapacity(size);
+ Iterator<? extends E> it = collection.iterator();
+ boolean changed = false;
+ while (size-- > 0) {
+ if (add(it.next())) {
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ /**
+ * Removes all of the elements in <tt>collection</tt> from the set.
+ *
+ * @param collection a <code>Collection</code> value
+ * @return true if the set was modified by the remove all operation.
+ */
+ @Override
+ public boolean removeAll(Collection<?> collection) {
+ int size = collection.size();
+
+ Iterator it = collection.iterator();
+ boolean changed = false;
+ while (size-- > 0) {
+ if (remove(it.next())) {
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ /**
+ * Removes any values in the set which are not contained in
+ * <tt>collection</tt>.
+ *
+ * @param collection a <code>Collection</code> value
+ * @return true if the set was modified by the retain all operation
+ */
+ @Override
+ public boolean retainAll(Collection<?> collection) {
+ int size = size();
+
+ Iterator it = iterator();
+ boolean changed = false;
+ while (size-- > 0) {
+ if (! collection.contains(it.next())) {
+ it.remove();
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEach(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ E val = (E) stream.readObject();
+ add(val);
+ }
+ }
+} // THashSet
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntArrayList.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntArrayList.java
new file mode 100755
index 0000000..bca0164
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntArrayList.java
@@ -0,0 +1,889 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Random;
+
+/**
+ * A resizable, array-backed list of int primitives.
+ *
+ * Created: Sat Dec 29 14:21:12 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TIntArrayList implements Serializable, Cloneable {
+
+ /** the data of the list */
+ protected transient int[] _data;
+
+ /** the index after the last entry in the list */
+ protected transient int _pos;
+
+ /** the default capacity for new lists */
+ protected static final int DEFAULT_CAPACITY = 4;
+
+ /**
+ * Creates a new <code>TIntArrayList</code> instance with the
+ * default capacity.
+ */
+ public TIntArrayList() {
+ this(DEFAULT_CAPACITY);
+ }
+
+ /**
+ * Creates a new <code>TIntArrayList</code> instance with the
+ * specified capacity.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ public TIntArrayList(int capacity) {
+ _data = new int[capacity];
+ _pos = 0;
+ }
+
+ /**
+ * Creates a new <code>TIntArrayList</code> instance whose
+ * capacity is the greater of the length of <tt>values</tt> and
+ * DEFAULT_CAPACITY and whose initial contents are the specified
+ * values.
+ *
+ * @param values an <code>int[]</code> value
+ */
+ public TIntArrayList(int[] values) {
+ this(Math.max(values.length, DEFAULT_CAPACITY));
+ add(values);
+ }
+
+ // sizing
+
+ /**
+ * Grow the internal array as needed to accomodate the specified
+ * number of elements. The size of the array doubles on each
+ * resize unless <tt>capacity</tt> requires more than twice the
+ * current capacity.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ public void ensureCapacity(int capacity) {
+ if (capacity > _data.length) {
+ int newCap = Math.max(_data.length << 1, capacity);
+ int[] tmp = new int[newCap];
+ System.arraycopy(_data, 0, tmp, 0, _data.length);
+ _data = tmp;
+ }
+ }
+
+ /**
+ * Returns the number of values in the list.
+ *
+ * @return the number of values in the list.
+ */
+ public int size() {
+ return _pos;
+ }
+
+ /**
+ * Tests whether this list contains any values.
+ *
+ * @return true if the list is empty.
+ */
+ public boolean isEmpty() {
+ return _pos == 0;
+ }
+
+ /**
+ * Sheds any excess capacity above and beyond the current size of
+ * the list.
+ */
+ public void trimToSize() {
+ if (_data.length > size()) {
+ int[] tmp = new int[size()];
+ toNativeArray(tmp, 0, tmp.length);
+ _data = tmp;
+ }
+ }
+
+ // modifying
+
+ /**
+ * Adds <tt>val</tt> to the end of the list, growing as needed.
+ *
+ * @param val an <code>int</code> value
+ */
+ public void add(int val) {
+ ensureCapacity(_pos + 1);
+ _data[_pos++] = val;
+ }
+
+ /**
+ * Adds the values in the array <tt>vals</tt> to the end of the
+ * list, in order.
+ *
+ * @param vals an <code>int[]</code> value
+ */
+ public void add(int[] vals) {
+ add(vals, 0, vals.length);
+ }
+
+ /**
+ * Adds a subset of the values in the array <tt>vals</tt> to the
+ * end of the list, in order.
+ *
+ * @param vals an <code>int[]</code> value
+ * @param offset the offset at which to start copying
+ * @param length the number of values to copy.
+ */
+ public void add(int[] vals, int offset, int length) {
+ ensureCapacity(_pos + length);
+ System.arraycopy(vals, offset, _data, _pos, length);
+ _pos += length;
+ }
+
+ /**
+ * Inserts <tt>value</tt> into the list at <tt>offset</tt>. All
+ * values including and to the right of <tt>offset</tt> are shifted
+ * to the right.
+ *
+ * @param offset an <code>int</code> value
+ * @param value an <code>int</code> value
+ */
+ public void insert(int offset, int value) {
+ if (offset == _pos) {
+ add(value);
+ return;
+ }
+ ensureCapacity(_pos + 1);
+ // shift right
+ System.arraycopy(_data, offset, _data, offset + 1, _pos - offset);
+ // insert
+ _data[offset] = value;
+ _pos++;
+ }
+
+ /**
+ * Inserts the array of <tt>values</tt> into the list at
+ * <tt>offset</tt>. All values including and to the right of
+ * <tt>offset</tt> are shifted to the right.
+ *
+ * @param offset an <code>int</code> value
+ * @param values an <code>int[]</code> value
+ */
+ public void insert(int offset, int[] values) {
+ insert(offset, values, 0, values.length);
+ }
+
+ /**
+ * Inserts a slice of the array of <tt>values</tt> into the list
+ * at <tt>offset</tt>. All values including and to the right of
+ * <tt>offset</tt> are shifted to the right.
+ *
+ * @param offset an <code>int</code> value
+ * @param values an <code>int[]</code> value
+ * @param valOffset the offset in the values array at which to
+ * start copying.
+ * @param len the number of values to copy from the values array
+ */
+ public void insert(int offset, int[] values, int valOffset, int len) {
+ if (offset == _pos) {
+ add(values, valOffset, len);
+ return;
+ }
+
+ ensureCapacity(_pos + len);
+ // shift right
+ System.arraycopy(_data, offset, _data, offset + len, _pos - offset);
+ // insert
+ System.arraycopy(values, valOffset, _data, offset, len);
+ _pos += len;
+ }
+
+ /**
+ * Returns the value at the specified offset.
+ *
+ * @param offset an <code>int</code> value
+ * @return an <code>int</code> value
+ */
+ public int get(int offset) {
+ if (offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ return _data[offset];
+ }
+
+ /**
+ * Returns the value at the specified offset without doing any
+ * bounds checking.
+ *
+ * @param offset an <code>int</code> value
+ * @return an <code>int</code> value
+ */
+ public int getQuick(int offset) {
+ return _data[offset];
+ }
+
+ /**
+ * Sets the value at the specified offset.
+ *
+ * @param offset an <code>int</code> value
+ * @param val an <code>int</code> value
+ */
+ public void set(int offset, int val) {
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ _data[offset] = val;
+ }
+
+ /**
+ * Sets the value at the specified offset and returns the
+ * previously stored value.
+ *
+ * @param offset an <code>int</code> value
+ * @param val an <code>int</code> value
+ * @return the value previously stored at offset.
+ */
+ public int getSet(int offset, int val) {
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ int old = _data[offset];
+ _data[offset] = val;
+ return old;
+ }
+
+ /**
+ * Replace the values in the list starting at <tt>offset</tt> with
+ * the contents of the <tt>values</tt> array.
+ *
+ * @param offset the first offset to replace
+ * @param values the source of the new values
+ */
+ public void set(int offset, int[] values) {
+ set(offset, values, 0, values.length);
+ }
+
+ /**
+ * Replace the values in the list starting at <tt>offset</tt> with
+ * <tt>length</tt> values from the <tt>values</tt> array, starting
+ * at valOffset.
+ *
+ * @param offset the first offset to replace
+ * @param values the source of the new values
+ * @param valOffset the first value to copy from the values array
+ * @param length the number of values to copy
+ */
+ public void set(int offset, int[] values, int valOffset, int length) {
+ if (offset < 0 || offset + length > _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ System.arraycopy(_data, offset, values, valOffset, length);
+ }
+
+ /**
+ * Sets the value at the specified offset without doing any bounds
+ * checking.
+ *
+ * @param offset an <code>int</code> value
+ * @param val an <code>int</code> value
+ */
+ public void setQuick(int offset, int val) {
+ _data[offset] = val;
+ }
+
+ /**
+ * Flushes the internal state of the list, resetting the capacity
+ * to the default.
+ */
+ public void clear() {
+ clear(DEFAULT_CAPACITY);
+ }
+
+ /**
+ * Flushes the internal state of the list, setting the capacity of
+ * the empty list to <tt>capacity</tt>.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ public void clear(int capacity) {
+ _data = new int[capacity];
+ _pos = 0;
+ }
+
+ /**
+ * Sets the size of the list to 0, but does not change its
+ * capacity. This method can be used as an alternative to the
+ * {@link #clear clear} method if you want to recyle a list without
+ * allocating new backing arrays.
+ *
+ * @see #clear
+ */
+ public void reset() {
+ _pos = 0;
+ fill(0);
+ }
+
+ /**
+ * Sets the size of the list to 0, but does not change its
+ * capacity. This method can be used as an alternative to the
+ * {@link #clear clear} method if you want to recyle a list
+ * without allocating new backing arrays. This method differs
+ * from {@link #reset reset} in that it does not clear the old
+ * values in the backing array. Thus, it is possible for {@link
+ * #getQuick getQuick} to return stale data if this method is used
+ * and the caller is careless about bounds checking.
+ *
+ * @see #reset
+ * @see #clear
+ * @see #getQuick
+ */
+ public void resetQuick() {
+ _pos = 0;
+ }
+
+ /**
+ * Removes the value at <tt>offset</tt> from the list.
+ *
+ * @param offset an <code>int</code> value
+ * @return the value previously stored at offset.
+ */
+ public int remove(int offset) {
+ int old = get(offset);
+ remove(offset, 1);
+ return old;
+ }
+
+ /**
+ * Removes <tt>length</tt> values from the list, starting at
+ * <tt>offset</tt>
+ *
+ * @param offset an <code>int</code> value
+ * @param length an <code>int</code> value
+ */
+ public void remove(int offset, int length) {
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+
+ if (offset == 0) {
+ // data at the front
+ System.arraycopy(_data, length, _data, 0, _pos - length);
+ } else if (_pos - length == offset) {
+ // no copy to make, decrementing pos "deletes" values at
+ // the end
+ } else {
+ // data in the middle
+ System.arraycopy(_data, offset + length,
+ _data, offset, _pos - (offset + length));
+ }
+ _pos -= length;
+ // no need to clear old values beyond _pos, because this is a
+ // primitive collection and 0 takes as much room as any other
+ // value
+ }
+
+ /**
+ * Transform each value in the list using the specified function.
+ *
+ * @param function a <code>TIntFunction</code> value
+ */
+ public void transformValues(TIntFunction function) {
+ for (int i = _pos; i-- > 0;) {
+ _data[i] = function.execute(_data[i]);
+ }
+ }
+
+ /**
+ * Reverse the order of the elements in the list.
+ */
+ public void reverse() {
+ reverse(0, _pos);
+ }
+
+ /**
+ * Reverse the order of the elements in the range of the list.
+ *
+ * @param from the inclusive index at which to start reversing
+ * @param to the exclusive index at which to stop reversing
+ */
+ public void reverse(int from, int to) {
+ if (from == to) {
+ return; // nothing to do
+ }
+ if (from > to) {
+ throw new IllegalArgumentException("from cannot be greater than to");
+ }
+ for (int i = from, j = to - 1; i < j; i++, j--) {
+ swap(i, j);
+ }
+ }
+
+ /**
+ * Shuffle the elements of the list using the specified random
+ * number generator.
+ *
+ * @param rand a <code>Random</code> value
+ */
+ public void shuffle(Random rand) {
+ for (int i = _pos; i-- > 1;) {
+ swap(i, rand.nextInt(i));
+ }
+ }
+
+ /**
+ * Swap the values at offsets <tt>i</tt> and <tt>j</tt>.
+ *
+ * @param i an offset into the data array
+ * @param j an offset into the data array
+ */
+ private void swap(int i, int j) {
+ int tmp = _data[i];
+ _data[i] = _data[j];
+ _data[j] = tmp;
+ }
+
+ // copying
+
+ /**
+ * Returns a clone of this list. Since this is a primitive
+ * collection, this will be a deep clone.
+ *
+ * @return a deep clone of the list.
+ */
+ @Override
+ public Object clone() {
+ TIntArrayList clone = null;
+ try {
+ clone = (TIntArrayList)super.clone();
+ clone._data = _data.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ // it's supported
+ } // end of try-catch
+ return clone;
+ }
+
+ /**
+ * Copies the contents of the list into a native array.
+ *
+ * @return an <code>int[]</code> value
+ */
+ public int[] toNativeArray() {
+ return toNativeArray(0, _pos);
+ }
+
+ /**
+ * Copies a slice of the list into a native array.
+ *
+ * @param offset the offset at which to start copying
+ * @param len the number of values to copy.
+ * @return an <code>int[]</code> value
+ */
+ public int[] toNativeArray(int offset, int len) {
+ int[] rv = new int[len];
+ toNativeArray(rv, offset, len);
+ return rv;
+ }
+
+ /**
+ * Copies a slice of the list into a native array.
+ *
+ * @param dest the array to copy into.
+ * @param offset the offset of the first value to copy
+ * @param len the number of values to copy.
+ */
+ public void toNativeArray(int[] dest, int offset, int len) {
+ if (len == 0) {
+ return; // nothing to copy
+ }
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ System.arraycopy(_data, offset, dest, 0, len);
+ }
+
+ // comparing
+
+ /**
+ * Compares this list to another list, value by value.
+ *
+ * @param other the object to compare against
+ * @return true if other is a TIntArrayList and has exactly the
+ * same values.
+ */
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ } else if (other instanceof TIntArrayList) {
+ TIntArrayList that = (TIntArrayList)other;
+ if (that.size() != this.size()) {
+ return false;
+ } else {
+ for (int i = _pos; i-- > 0;) {
+ if (this._data[i] != that._data[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ int h = 0;
+ for (int i = _pos; i-- > 0;) {
+ h += HashFunctions.hash(_data[i]);
+ }
+ return h;
+ }
+
+ // procedures
+
+ /**
+ * Applies the procedure to each value in the list in ascending
+ * (front to back) order.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return true if the procedure did not terminate prematurely.
+ */
+ public boolean forEach(TIntProcedure procedure) {
+ for (int i = 0; i < _pos; i++) {
+ if (! procedure.execute(_data[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Applies the procedure to each value in the list in descending
+ * (back to front) order.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return true if the procedure did not terminate prematurely.
+ */
+ public boolean forEachDescending(TIntProcedure procedure) {
+ for (int i = _pos; i-- > 0;) {
+ if (! procedure.execute(_data[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // sorting
+
+ /**
+ * Sort the values in the list (ascending) using the Sun quicksort
+ * implementation.
+ *
+ * @see java.util.Arrays#sort
+ */
+ public void sort() {
+ Arrays.sort(_data, 0, _pos);
+ }
+
+ /**
+ * Sort a slice of the list (ascending) using the Sun quicksort
+ * implementation.
+ *
+ * @param fromIndex the index at which to start sorting (inclusive)
+ * @param toIndex the index at which to stop sorting (exclusive)
+ * @see java.util.Arrays#sort
+ */
+ public void sort(int fromIndex, int toIndex) {
+ Arrays.sort(_data, fromIndex, toIndex);
+ }
+
+ // filling
+
+ /**
+ * Fills every slot in the list with the specified value.
+ *
+ * @param val the value to use when filling
+ */
+ public void fill(int val) {
+ Arrays.fill(_data, 0, _pos, val);
+ }
+
+ /**
+ * Fills a range in the list with the specified value.
+ *
+ * @param fromIndex the offset at which to start filling (inclusive)
+ * @param toIndex the offset at which to stop filling (exclusive)
+ * @param val the value to use when filling
+ */
+ public void fill(int fromIndex, int toIndex, int val) {
+ if (toIndex > _pos) {
+ ensureCapacity(toIndex);
+ _pos = toIndex;
+ }
+ Arrays.fill(_data, fromIndex, toIndex, val);
+ }
+
+ // searching
+
+ /**
+ * Performs a binary search for <tt>value</tt> in the entire list.
+ * Note that you <b>must</b> {@link #sort sort} the list before
+ * doing a search.
+ *
+ * @param value the value to search for
+ * @return the absolute offset in the list of the value, or its
+ * negative insertion point into the sorted list.
+ */
+ public int binarySearch(int value) {
+ return binarySearch(value, 0, _pos);
+ }
+
+ /**
+ * Performs a binary search for <tt>value</tt> in the specified
+ * range. Note that you <b>must</b> {@link #sort sort} the list
+ * or the range before doing a search.
+ *
+ * @param value the value to search for
+ * @param fromIndex the lower boundary of the range (inclusive)
+ * @param toIndex the upper boundary of the range (exclusive)
+ * @return the absolute offset in the list of the value, or its
+ * negative insertion point into the sorted list.
+ */
+ public int binarySearch(int value, int fromIndex, int toIndex) {
+ if (fromIndex < 0) {
+ throw new ArrayIndexOutOfBoundsException(fromIndex);
+ }
+ if (toIndex > _pos) {
+ throw new ArrayIndexOutOfBoundsException(toIndex);
+ }
+
+ int low = fromIndex;
+ int high = toIndex - 1;
+
+ while (low <= high) {
+ int mid = (low + high) >> 1;
+ int midVal = _data[mid];
+
+ if (midVal < value) {
+ low = mid + 1;
+ } else if (midVal > value) {
+ high = mid - 1;
+ } else {
+ return mid; // value found
+ }
+ }
+ return -(low + 1); // value not found.
+ }
+
+ /**
+ * Searches the list front to back for the index of
+ * <tt>value</tt>.
+ *
+ * @param value an <code>int</code> value
+ * @return the first offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int indexOf(int value) {
+ return indexOf(0, value);
+ }
+
+ /**
+ * Searches the list front to back for the index of
+ * <tt>value</tt>, starting at <tt>offset</tt>.
+ *
+ * @param offset the offset at which to start the linear search
+ * (inclusive)
+ * @param value an <code>int</code> value
+ * @return the first offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int indexOf(int offset, int value) {
+ for (int i = offset; i < _pos; i++) {
+ if (_data[i] == value) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Searches the list back to front for the last index of
+ * <tt>value</tt>.
+ *
+ * @param value an <code>int</code> value
+ * @return the last offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int lastIndexOf(int value) {
+ return lastIndexOf(_pos, value);
+ }
+
+ /**
+ * Searches the list back to front for the last index of
+ * <tt>value</tt>, starting at <tt>offset</tt>.
+ *
+ * @param offset the offset at which to start the linear search
+ * (exclusive)
+ * @param value an <code>int</code> value
+ * @return the last offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int lastIndexOf(int offset, int value) {
+ for (int i = offset; i-- > 0;) {
+ if (_data[i] == value) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Searches the list for <tt>value</tt>
+ *
+ * @param value an <code>int</code> value
+ * @return true if value is in the list.
+ */
+ public boolean contains(int value) {
+ return lastIndexOf(value) >= 0;
+ }
+
+ /**
+ * Searches the list for values satisfying <tt>condition</tt> in
+ * the manner of the *nix <tt>grep</tt> utility.
+ *
+ * @param condition a condition to apply to each element in the list
+ * @return a list of values which match the condition.
+ */
+ public TIntArrayList grep(TIntProcedure condition) {
+ TIntArrayList list = new TIntArrayList();
+ for (int i = 0; i < _pos; i++) {
+ if (condition.execute(_data[i])) {
+ list.add(_data[i]);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Searches the list for values which do <b>not</b> satisfy
+ * <tt>condition</tt>. This is akin to *nix <code>grep -v</code>.
+ *
+ * @param condition a condition to apply to each element in the list
+ * @return a list of values which do not match the condition.
+ */
+ public TIntArrayList inverseGrep(TIntProcedure condition) {
+ TIntArrayList list = new TIntArrayList();
+ for (int i = 0; i < _pos; i++) {
+ if (! condition.execute(_data[i])) {
+ list.add(_data[i]);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Finds the maximum value in the list.
+ *
+ * @return the largest value in the list.
+ * @exception IllegalStateException if the list is empty
+ */
+ public int max() {
+ if (size() == 0) {
+ throw new IllegalStateException("cannot find maximum of an empty list");
+ }
+ int max = _data[_pos - 1];
+ for (int i = _pos - 1; i-- > 0;) {
+ max = Math.max(max, _data[_pos]);
+ }
+ return max;
+ }
+
+ /**
+ * Finds the minimum value in the list.
+ *
+ * @return the smallest value in the list.
+ * @exception IllegalStateException if the list is empty
+ */
+ public int min() {
+ if (size() == 0) {
+ throw new IllegalStateException("cannot find minimum of an empty list");
+ }
+ int min = _data[_pos - 1];
+ for (int i = _pos - 1; i-- > 0;) {
+ min = Math.min(min, _data[_pos]);
+ }
+ return min;
+ }
+
+ // stringification
+
+ /**
+ * Returns a String representation of the list, front to back.
+ *
+ * @return a <code>String</code> value
+ */
+ public String toString() {
+ final StringBuffer buf = new StringBuffer("{");
+ forEach(new TIntProcedure() {
+ @Override
+ public boolean execute(int val) {
+ buf.append(val);
+ buf.append(", ");
+ return true;
+ }
+ });
+ buf.append("}");
+ return buf.toString();
+ }
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(size());
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEach(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ _data = new int[size];
+ while (size-- > 0) {
+ int val = stream.readInt();
+ add(val);
+ }
+ }
+
+} // TIntArrayList
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntDoubleHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntDoubleHashMap.java
new file mode 100755
index 0000000..9c8b333
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntDoubleHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for int keys and double values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TIntDoubleHashMap extends TIntHash {
+
+ /** the values of the map */
+ protected transient double[] _values;
+
+ /**
+ * Creates a new <code>TIntDoubleHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TIntDoubleHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TIntDoubleHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TIntDoubleHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TIntDoubleHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TIntDoubleHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TIntDoubleHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntDoubleHashMap(TIntHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TIntDoubleHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntDoubleHashMap(int initialCapacity, TIntHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TIntDoubleHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntDoubleHashMap(int initialCapacity, float loadFactor, TIntHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TIntDoubleHashMap m = (TIntDoubleHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TIntDoubleIterator with access to this map's keys and values
+ */
+ public TIntDoubleIterator iterator() {
+ return new TIntDoubleIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new double[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>int</code> value
+ * @param value an <code>double</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public double put(int key, double value) {
+ double previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ int[] oldKeys = _set;
+ double[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new int[newCapacity];
+ _values = new double[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ int o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>int</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public double get(int key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ int[] keys = _set;
+ double[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>int</code> value
+ * @return an <code>double</code> value
+ */
+ public double remove(int key) {
+ double prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TIntDoubleHashMap)) {
+ return false;
+ }
+ TIntDoubleHashMap that = (TIntDoubleHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TIntDoubleProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(int key, double value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TIntDoubleProcedure {
+ private final TIntDoubleHashMap _otherMap;
+
+ EqProcedure(TIntDoubleHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(int key, double value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two doubles for equality.
+ */
+ private static boolean eq(double v1, double v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public double[] getValues() {
+ double[] vals = new double[size()];
+ double[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public int[] keys() {
+ int[] keys = new int[size()];
+ int[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>double</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(double val) {
+ byte[] states = _states;
+ double[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>int</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(int key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TIntProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TDoubleProcedure procedure) {
+ byte[] states = _states;
+ double[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TIntDoubleProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TIntDoubleProcedure procedure) {
+ byte[] states = _states;
+ int[] keys = _set;
+ double[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TIntDoubleProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ int[] keys = _set;
+ double[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TDoubleFunction</code> value
+ */
+ public void transformValues(TDoubleFunction function) {
+ byte[] states = _states;
+ double[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(int key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(int key, double amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ int key = stream.readInt();
+ double val = stream.readDouble();
+ put(key, val);
+ }
+ }
+} // TIntDoubleHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntDoubleIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntDoubleIterator.java
new file mode 100755
index 0000000..8b59708
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntDoubleIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type int and double.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TIntDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TIntDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TIntDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TIntDoubleIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TIntDoubleIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TIntDoubleHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TIntDoubleIterator(TIntDoubleHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public int key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public double value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public double setValue(double val) {
+ double old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TIntDoubleIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntDoubleProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntDoubleProcedure.java
new file mode 100755
index 0000000..e77b4d7
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntDoubleProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type int and double.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TIntDoubleProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>int</code> value
+ * @param b an <code>double</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(int a, double b);
+}// TIntDoubleProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntFloatHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntFloatHashMap.java
new file mode 100755
index 0000000..71761f0
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntFloatHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for int keys and float values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TIntFloatHashMap extends TIntHash {
+
+ /** the values of the map */
+ protected transient float[] _values;
+
+ /**
+ * Creates a new <code>TIntFloatHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TIntFloatHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TIntFloatHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TIntFloatHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TIntFloatHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TIntFloatHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TIntFloatHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntFloatHashMap(TIntHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TIntFloatHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntFloatHashMap(int initialCapacity, TIntHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TIntFloatHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntFloatHashMap(int initialCapacity, float loadFactor, TIntHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TIntFloatHashMap m = (TIntFloatHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TIntFloatIterator with access to this map's keys and values
+ */
+ public TIntFloatIterator iterator() {
+ return new TIntFloatIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new float[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>int</code> value
+ * @param value an <code>float</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public float put(int key, float value) {
+ float previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ int[] oldKeys = _set;
+ float[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new int[newCapacity];
+ _values = new float[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ int o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>int</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public float get(int key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ int[] keys = _set;
+ float[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>int</code> value
+ * @return an <code>float</code> value
+ */
+ public float remove(int key) {
+ float prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TIntFloatHashMap)) {
+ return false;
+ }
+ TIntFloatHashMap that = (TIntFloatHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TIntFloatProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(int key, float value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TIntFloatProcedure {
+ private final TIntFloatHashMap _otherMap;
+
+ EqProcedure(TIntFloatHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(int key, float value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two floats for equality.
+ */
+ private static boolean eq(float v1, float v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public float[] getValues() {
+ float[] vals = new float[size()];
+ float[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public int[] keys() {
+ int[] keys = new int[size()];
+ int[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>float</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(float val) {
+ byte[] states = _states;
+ float[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>int</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(int key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TIntProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TFloatProcedure procedure) {
+ byte[] states = _states;
+ float[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TIntFloatProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TIntFloatProcedure procedure) {
+ byte[] states = _states;
+ int[] keys = _set;
+ float[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TIntFloatProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ int[] keys = _set;
+ float[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TFloatFunction</code> value
+ */
+ public void transformValues(TFloatFunction function) {
+ byte[] states = _states;
+ float[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(int key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(int key, float amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ int key = stream.readInt();
+ float val = stream.readFloat();
+ put(key, val);
+ }
+ }
+} // TIntFloatHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntFloatIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntFloatIterator.java
new file mode 100755
index 0000000..2810dee
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntFloatIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type int and float.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TIntFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TIntFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TIntFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TIntFloatIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TIntFloatIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TIntFloatHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TIntFloatIterator(TIntFloatHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public int key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public float value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public float setValue(float val) {
+ float old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TIntFloatIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntFloatProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntFloatProcedure.java
new file mode 100755
index 0000000..bb703ab
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntFloatProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type int and float.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TIntFloatProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>int</code> value
+ * @param b an <code>float</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(int a, float b);
+}// TIntFloatProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntFunction.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntFunction.java
new file mode 100755
index 0000000..e196bf1
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntFunction.java
@@ -0,0 +1,37 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for functions that accept and return one int primitive.
+ *
+ * Created: Mon Nov 5 22:19:36 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TIntFunction {
+ /**
+ * Execute this function with <tt>value</tt>
+ *
+ * @param value an <code>int</code> input
+ * @return an <code>int</code> result
+ */
+ int execute(int value);
+}// TIntFunction
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntHash.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntHash.java
new file mode 100755
index 0000000..e1f79f0
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntHash.java
@@ -0,0 +1,261 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * An open addressed hashing implementation for int primitives.
+ *
+ * Created: Sun Nov 4 08:56:06 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+abstract public class TIntHash extends TPrimitiveHash
+ implements TIntHashingStrategy {
+
+ /** the set of ints */
+ protected transient int[] _set;
+
+ /** strategy used to hash values in this collection */
+ protected TIntHashingStrategy _hashingStrategy;
+
+ /**
+ * Creates a new <code>TIntHash</code> instance with the default
+ * capacity and load factor.
+ */
+ public TIntHash() {
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TIntHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TIntHash(int initialCapacity) {
+ super(initialCapacity);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TIntHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ */
+ public TIntHash(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TIntHash</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntHash(TIntHashingStrategy strategy) {
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TIntHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntHash(int initialCapacity, TIntHashingStrategy strategy) {
+ super(initialCapacity);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TIntHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntHash(int initialCapacity, float loadFactor, TIntHashingStrategy strategy) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TIntHash h = (TIntHash)super.clone();
+ h._set = _set.clone();
+ return h;
+ }
+
+ /**
+ * initializes the hash table to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _set = new int[capacity];
+ return capacity;
+ }
+
+ /**
+ * Searches the set for <tt>val</tt>
+ *
+ * @param val an <code>int</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean contains(int val) {
+ return index(val) >= 0;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each element in the set.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the set terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEach(TIntProcedure procedure) {
+ byte[] states = _states;
+ int[] set = _set;
+ for (int i = set.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(set[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Releases the element currently stored at <tt>index</tt>.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _set[index] = (int)0;
+ super.removeAt(index);
+ }
+
+ /**
+ * Locates the index of <tt>val</tt>.
+ *
+ * @param val an <code>int</code> value
+ * @return the index of <tt>val</tt> or -1 if it isn't in the set.
+ */
+ protected int index(int val) {
+ byte[] states = _states;
+ int[] set = _set;
+ int length = states.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (states[index] != FREE &&
+ (states[index] == REMOVED || set[index] != val)) {
+ // see Knuth, p. 529
+ int probe = 1 + (hash % (length - 2));
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ } while (states[index] != FREE &&
+ (states[index] == REMOVED || set[index] != val));
+ }
+
+ return states[index] == FREE ? -1 : index;
+ }
+
+ /**
+ * Locates the index at which <tt>val</tt> can be inserted. if
+ * there is already a value equal()ing <tt>val</tt> in the set,
+ * returns that value as a negative integer.
+ *
+ * @param val an <code>int</code> value
+ * @return an <code>int</code> value
+ */
+ protected int insertionIndex(int val) {
+ byte[] states = _states;
+ int[] set = _set;
+ int length = states.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (states[index] == FREE) {
+ return index; // empty, all done
+ } else if (states[index] == FULL && set[index] == val) {
+ return -index -1; // already stored
+ } else { // already FULL or REMOVED, must probe
+ // compute the double hash
+ int probe = 1 + (hash % (length - 2));
+ // starting at the natural offset, probe until we find an
+ // offset that isn't full.
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ } while (states[index] == FULL && set[index] != val);
+
+ // if the index we found was removed: continue probing until we
+ // locate a free location or an element which equal()s the
+ // one we have.
+ if (states[index] == REMOVED) {
+ int firstRemoved = index;
+ while (states[index] != FREE &&
+ (states[index] == REMOVED || set[index] != val)) {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ }
+ return states[index] == FULL ? -index -1 : firstRemoved;
+ }
+ // if it's full, the key is already stored
+ return states[index] == FULL ? -index -1 : index;
+ }
+ }
+
+ /**
+ * Default implementation of TIntHashingStrategy:
+ * delegates hashing to HashFunctions.hash(int).
+ *
+ * @param val the value to hash
+ * @return the hash code.
+ */
+ @Override
+ public final int computeHashCode(int val) {
+ return HashFunctions.hash(val);
+ }
+} // TIntHash
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntHashSet.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntHashSet.java
new file mode 100755
index 0000000..7b56bcd
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntHashSet.java
@@ -0,0 +1,363 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Arrays;
+
+/**
+ * An open addressed set implementation for int primitives.
+ *
+ * Created: Sat Nov 3 10:38:17 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TIntHashSet extends TIntHash {
+
+ /**
+ * Creates a new <code>TIntHashSet</code> instance with the default
+ * capacity and load factor.
+ */
+ public TIntHashSet() {
+ }
+
+ /**
+ * Creates a new <code>TIntHashSet</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TIntHashSet(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TIntHashSet</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TIntHashSet(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TIntHashSet</code> instance containing the
+ * elements of <tt>array</tt>.
+ *
+ * @param array an array of <code>int</code> primitives
+ */
+ public TIntHashSet(int[] array) {
+ this(array.length);
+ addAll(array);
+ }
+
+ /**
+ * Creates a new <code>TIntHash</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntHashSet(TIntHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TIntHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntHashSet(int initialCapacity, TIntHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TIntHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntHashSet(int initialCapacity, float loadFactor, TIntHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * Creates a new <code>TIntHashSet</code> instance containing the
+ * elements of <tt>array</tt>.
+ *
+ * @param array an array of <code>int</code> primitives
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntHashSet(int[] array, TIntHashingStrategy strategy) {
+ this(array.length, strategy);
+ addAll(array);
+ }
+
+ /**
+ * @return a TIntIterator with access to the values in this set
+ */
+ public TIntIterator iterator() {
+ return new TIntIterator(this);
+ }
+
+ /**
+ * Inserts a value into the set.
+ *
+ * @param val an <code>int</code> value
+ * @return true if the set was modified by the add operation
+ */
+ public boolean add(int val) {
+ int index = insertionIndex(val);
+
+ if (index < 0) {
+ return false; // already present in set, nothing to add
+ }
+
+ byte previousState = _states[index];
+ _set[index] = val;
+ _states[index] = FULL;
+ postInsertHook(previousState == FREE);
+
+ return true; // yes, we added something
+ }
+
+ /**
+ * Expands the set to accommodate new values.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ int[] oldSet = _set;
+ byte[] oldStates = _states;
+
+ _set = new int[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ int o = oldSet[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * Returns a new array containing the values in the set.
+ *
+ * @return an <code>int[]</code> value
+ */
+ public int[] toArray() {
+ int[] result = new int[size()];
+ int[] set = _set;
+ byte[] states = _states;
+
+ for (int i = states.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ result[j++] = set[i];
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Empties the set.
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ int[] set = _set;
+ byte[] states = _states;
+
+ for (int i = set.length; i-- > 0;) {
+ set[i] = (int)0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Compares this set with another set for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TIntHashSet)) {
+ return false;
+ }
+ final TIntHashSet that = (TIntHashSet)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEach(new TIntProcedure() {
+ @Override
+ public final boolean execute(int value) {
+ return that.contains(value);
+ }
+ });
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEach(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TIntProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(int key) {
+ h += _hashingStrategy.computeHashCode(key);
+ return true;
+ }
+ }
+
+ /**
+ * Removes <tt>val</tt> from the set.
+ *
+ * @param val an <code>int</code> value
+ * @return true if the set was modified by the remove operation.
+ */
+ public boolean remove(int val) {
+ int index = index(val);
+ if (index >= 0) {
+ removeAt(index);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Tests the set to determine if all of the elements in
+ * <tt>array</tt> are present.
+ *
+ * @param array an <code>array</code> of int primitives.
+ * @return true if all elements were present in the set.
+ */
+ public boolean containsAll(int[] array) {
+ for (int i = array.length; i-- > 0;) {
+ if (! contains(array[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Adds all of the elements in <tt>array</tt> to the set.
+ *
+ * @param array an <code>array</code> of int primitives.
+ * @return true if the set was modified by the add all operation.
+ */
+ public boolean addAll(int[] array) {
+ boolean changed = false;
+ for (int i = array.length; i-- > 0;) {
+ if (add(array[i])) {
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ /**
+ * Removes all of the elements in <tt>array</tt> from the set.
+ *
+ * @param array an <code>array</code> of int primitives.
+ * @return true if the set was modified by the remove all operation.
+ */
+ public boolean removeAll(int[] array) {
+ boolean changed = false;
+ for (int i = array.length; i-- > 0;) {
+ if (remove(array[i])) {
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ /**
+ * Removes any values in the set which are not contained in
+ * <tt>array</tt>.
+ *
+ * @param array an <code>array</code> of int primitives.
+ * @return true if the set was modified by the retain all operation
+ */
+ public boolean retainAll(int[] array) {
+ Arrays.sort(array);
+ int[] set = _set;
+ byte[] states = _states;
+
+ boolean changed = false;
+ for (int i = set.length; i-- > 0;) {
+ if (states[i] == FULL && Arrays.binarySearch(array,set[i]) < 0) {
+ remove(set[i]);
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEach(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ int val = stream.readInt();
+ add(val);
+ }
+ }
+} // TIntHashSet
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntHashingStrategy.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntHashingStrategy.java
new file mode 100755
index 0000000..a9e68e9
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntHashingStrategy.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.Serializable;
+
+/**
+ * Interface to support pluggable hashing strategies in maps and sets.
+ * Implementors can use this interface to make the trove hashing
+ * algorithms use an optimal strategy when computing hashcodes.
+ *
+ * Created: Sun Nov 4 08:56:06 2001
+ *
+ * @author Eric D. Friedman
+ */
+public interface TIntHashingStrategy extends Serializable {
+ /**
+ * Computes a hash code for the specified int. Implementors
+ * can use the int's own value or a custom scheme designed to
+ * minimize collisions for a known set of input.
+ *
+ * @param val int for which the hashcode is to be computed
+ * @return the hashCode
+ */
+ public int computeHashCode(int val);
+} // TIntHashingStrategy
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntIntHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntIntHashMap.java
new file mode 100755
index 0000000..cd4ce85
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntIntHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for int keys and int values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TIntIntHashMap extends TIntHash {
+
+ /** the values of the map */
+ protected transient int[] _values;
+
+ /**
+ * Creates a new <code>TIntIntHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TIntIntHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TIntIntHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TIntIntHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TIntIntHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TIntIntHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TIntIntHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntIntHashMap(TIntHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TIntIntHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntIntHashMap(int initialCapacity, TIntHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TIntIntHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntIntHashMap(int initialCapacity, float loadFactor, TIntHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TIntIntHashMap m = (TIntIntHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TIntIntIterator with access to this map's keys and values
+ */
+ public TIntIntIterator iterator() {
+ return new TIntIntIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new int[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>int</code> value
+ * @param value an <code>int</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public int put(int key, int value) {
+ int previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ int[] oldKeys = _set;
+ int[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new int[newCapacity];
+ _values = new int[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ int o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>int</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public int get(int key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ int[] keys = _set;
+ int[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>int</code> value
+ * @return an <code>int</code> value
+ */
+ public int remove(int key) {
+ int prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TIntIntHashMap)) {
+ return false;
+ }
+ TIntIntHashMap that = (TIntIntHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TIntIntProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(int key, int value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TIntIntProcedure {
+ private final TIntIntHashMap _otherMap;
+
+ EqProcedure(TIntIntHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(int key, int value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two ints for equality.
+ */
+ private static boolean eq(int v1, int v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public int[] getValues() {
+ int[] vals = new int[size()];
+ int[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public int[] keys() {
+ int[] keys = new int[size()];
+ int[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>int</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(int val) {
+ byte[] states = _states;
+ int[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>int</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(int key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TIntProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TIntProcedure procedure) {
+ byte[] states = _states;
+ int[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TIntIntProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TIntIntProcedure procedure) {
+ byte[] states = _states;
+ int[] keys = _set;
+ int[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TIntIntProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ int[] keys = _set;
+ int[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TIntFunction</code> value
+ */
+ public void transformValues(TIntFunction function) {
+ byte[] states = _states;
+ int[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(int key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(int key, int amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ int key = stream.readInt();
+ int val = stream.readInt();
+ put(key, val);
+ }
+ }
+} // TIntIntHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntIntIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntIntIterator.java
new file mode 100755
index 0000000..442368c
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntIntIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type int and int.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TIntIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TIntIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TIntIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TIntIntIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TIntIntIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TIntIntHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TIntIntIterator(TIntIntHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public int key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public int value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public int setValue(int val) {
+ int old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TIntIntIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntIntProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntIntProcedure.java
new file mode 100755
index 0000000..2380305
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntIntProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type int and int.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TIntIntProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>int</code> value
+ * @param b an <code>int</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(int a, int b);
+}// TIntIntProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntIterator.java
new file mode 100755
index 0000000..da74579
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntIterator.java
@@ -0,0 +1,53 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for int collections.
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TIntIterator extends TPrimitiveIterator {
+ /**
+ * the collection on which the iterator operates
+ */
+ private final TIntHash _hash;
+
+ /**
+ * Creates a TIntIterator for the elements in the specified collection.
+ */
+ public TIntIterator(TIntHash hash) {
+ super(hash);
+ _hash = hash;
+ }
+
+ /**
+ * Advances the iterator to the next element in the underlying collection
+ * and returns it.
+ *
+ * @return the next int in the collection
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public int next() {
+ moveToNextIndex();
+ return _hash._set[_index];
+ }
+}// TIntIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntLongHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntLongHashMap.java
new file mode 100755
index 0000000..9c5aaec
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntLongHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for int keys and long values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TIntLongHashMap extends TIntHash {
+
+ /** the values of the map */
+ protected transient long[] _values;
+
+ /**
+ * Creates a new <code>TIntLongHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TIntLongHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TIntLongHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TIntLongHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TIntLongHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TIntLongHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TIntLongHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntLongHashMap(TIntHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TIntLongHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntLongHashMap(int initialCapacity, TIntHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TIntLongHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntLongHashMap(int initialCapacity, float loadFactor, TIntHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TIntLongHashMap m = (TIntLongHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TIntLongIterator with access to this map's keys and values
+ */
+ public TIntLongIterator iterator() {
+ return new TIntLongIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new long[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>int</code> value
+ * @param value an <code>long</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public long put(int key, long value) {
+ long previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ int[] oldKeys = _set;
+ long[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new int[newCapacity];
+ _values = new long[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ int o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>int</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public long get(int key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ int[] keys = _set;
+ long[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>int</code> value
+ * @return an <code>long</code> value
+ */
+ public long remove(int key) {
+ long prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TIntLongHashMap)) {
+ return false;
+ }
+ TIntLongHashMap that = (TIntLongHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TIntLongProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(int key, long value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TIntLongProcedure {
+ private final TIntLongHashMap _otherMap;
+
+ EqProcedure(TIntLongHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(int key, long value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two longs for equality.
+ */
+ private static boolean eq(long v1, long v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public long[] getValues() {
+ long[] vals = new long[size()];
+ long[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public int[] keys() {
+ int[] keys = new int[size()];
+ int[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>long</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(long val) {
+ byte[] states = _states;
+ long[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>int</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(int key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TIntProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TLongProcedure procedure) {
+ byte[] states = _states;
+ long[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TIntLongProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TIntLongProcedure procedure) {
+ byte[] states = _states;
+ int[] keys = _set;
+ long[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TIntLongProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ int[] keys = _set;
+ long[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TLongFunction</code> value
+ */
+ public void transformValues(TLongFunction function) {
+ byte[] states = _states;
+ long[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(int key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(int key, long amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ int key = stream.readInt();
+ long val = stream.readLong();
+ put(key, val);
+ }
+ }
+} // TIntLongHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntLongIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntLongIterator.java
new file mode 100755
index 0000000..ea7ff33
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntLongIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type int and long.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TIntLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TIntLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TIntLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TIntLongIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TIntLongIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TIntLongHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TIntLongIterator(TIntLongHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public int key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public long value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public long setValue(long val) {
+ long old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TIntLongIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntLongProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntLongProcedure.java
new file mode 100755
index 0000000..88430c2
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntLongProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type int and long.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TIntLongProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>int</code> value
+ * @param b an <code>long</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(int a, long b);
+}// TIntLongProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntObjectHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntObjectHashMap.java
new file mode 100755
index 0000000..a66384d
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntObjectHashMap.java
@@ -0,0 +1,668 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for int keys and Object values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TIntObjectHashMap<V> extends THash implements TIntHashingStrategy {
+
+ /** the values of the map */
+ protected transient V[] _values;
+
+ /** the set of ints */
+ protected transient int[] _set;
+
+ /** strategy used to hash values in this collection */
+ protected final TIntHashingStrategy _hashingStrategy;
+
+ /**
+ * Creates a new <code>TIntObjectHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TIntObjectHashMap() {
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TIntObjectHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TIntObjectHashMap(int initialCapacity) {
+ super(initialCapacity);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TIntObjectHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TIntObjectHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TIntObjectHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntObjectHashMap(TIntHashingStrategy strategy) {
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TIntObjectHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntObjectHashMap(int initialCapacity, TIntHashingStrategy strategy) {
+ super(initialCapacity);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TIntObjectHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TIntObjectHashMap(int initialCapacity, float loadFactor, TIntHashingStrategy strategy) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public TIntObjectHashMap<V> clone() {
+ TIntObjectHashMap<V> m = (TIntObjectHashMap<V>)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TIntObjectIterator with access to this map's keys and values
+ */
+ public TIntObjectIterator<V> iterator() {
+ return new TIntObjectIterator<V>(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = (V[]) new Object[capacity];
+ _set = new int[capacity];
+
+ return capacity;
+ }
+
+ /**
+ * Searches the set for <tt>val</tt>
+ *
+ * @param val an <code>int</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean contains(int val) {
+ return index(val) >= 0;
+ }
+
+
+ /**
+ * Returns the capacity of the hash table. This is the true
+ * physical capacity, without adjusting for the load factor.
+ *
+ * @return the physical capacity of the hash table.
+ */
+ @Override
+ protected int capacity() {
+ return _values.length;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each element in the set.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return false if the loop over the set terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEach(TIntProcedure procedure) {
+ int[] set = _set;
+ Object[] values = _values;
+ for (int i = set.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(set[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>int</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public V put(int key, V value) {
+ boolean wasFree = false;
+ V previous = null;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = unwrapNull(_values[index]);
+ isNewMapping = false;
+ }
+ else {
+ wasFree = isFree(_values, index);
+ }
+ _set[index] = key;
+ _values[index] = wrapNull(value);
+ if (isNewMapping) {
+ postInsertHook(wasFree);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ int[] oldKeys = _set;
+ V[] oldVals = _values;
+
+ _set = new int[newCapacity];
+ _values = (V[]) new Object[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(isFull(oldVals, i)) {
+ int o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>int</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public V get(int key) {
+ int index = index(key);
+ return index < 0 ? null : unwrapNull(_values[index]);
+ }
+
+ private static <V> V unwrapNull(V value) {
+ return value == TObjectHash.NULL ? null : value;
+ }
+ private static <V> V wrapNull(V value) {
+ return value == null ? (V)TObjectHash.NULL : value;
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ int[] keys = _set;
+ Object[] values = _values;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = (int)0;
+ values[i] = null;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>int</code> value
+ * @return an <code>Object</code> value
+ */
+ public V remove(int key) {
+ V prev = null;
+ int index = index(key);
+ if (index >= 0) {
+ prev = unwrapNull(_values[index]);
+ removeAt(index); // clear key,set; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Locates the index of <tt>val</tt>.
+ *
+ * @param val an <code>int</code> value
+ * @return the index of <tt>val</tt> or -1 if it isn't in the set.
+ */
+ protected int index(int val) {
+ int[] set = _set;
+ Object[] values = _values;
+ int length = set.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (!isFree(values, index) &&
+ (isRemoved(values, index) || set[index] != val)) {
+ // see Knuth, p. 529
+ int probe = 1 + (hash % (length - 2));
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ } while (!isFree(values, index) &&
+ (isRemoved(values, index) || set[index] != val));
+ }
+
+ return isFree(values, index) ? -1 : index;
+ }
+
+ /**
+ * Locates the index at which <tt>val</tt> can be inserted. if
+ * there is already a value equal()ing <tt>val</tt> in the set,
+ * returns that value as a negative integer.
+ *
+ * @param val an <code>int</code> value
+ * @return an <code>int</code> value
+ */
+ protected int insertionIndex(int val) {
+ Object[] values = _values;
+ int[] set = _set;
+ int length = set.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (isFree(values, index)) {
+ return index; // empty, all done
+ }
+ if (isFull(values, index) && set[index] == val) {
+ return -index -1; // already stored
+ }
+
+ // already FULL or REMOVED, must probe
+ // compute the double hash
+ int probe = 1 + (hash % (length - 2));
+ // starting at the natural offset, probe until we find an
+ // offset that isn't full.
+
+ // keep track of the first removed cell. it's the natural candidate for re-insertion
+ int firstRemoved = isRemoved(values, index) ? index : -1;
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ if (firstRemoved == -1 && isRemoved(values, index)) {
+ firstRemoved = index;
+ }
+ }
+ while (isFull(values, index) && set[index] != val);
+
+ // if the index we found was removed: continue probing until we
+ // locate a free location or an element which equal()s the
+ // one we have.
+ if (isRemoved(values, index)) {
+ while (!isFree(values, index) &&
+ (isRemoved(values, index) || set[index] != val)) {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ }
+ }
+ // if it's full, the key is already stored
+ if (isFull(values, index)) {
+ return -index -1;
+ }
+
+ return firstRemoved == -1 ? index : firstRemoved;
+ }
+
+ static boolean isFull(Object[] values, int index) {
+ Object value = values[index];
+ return value != null && value != TObjectHash.REMOVED;
+ }
+
+ private static boolean isRemoved(Object[] values, int index) {
+ return values[index] == TObjectHash.REMOVED;
+ }
+
+ private static boolean isFree(Object[] values, int index) {
+ return values[index] == null;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TIntObjectHashMap)) {
+ return false;
+ }
+ TIntObjectHashMap that = (TIntObjectHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure<V>(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TIntObjectProcedure<V> {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(int key, V value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure<V> implements TIntObjectProcedure<V> {
+ private final TIntObjectHashMap<V> _otherMap;
+
+ EqProcedure(TIntObjectHashMap<V> otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(int key, V value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two objects for equality.
+ */
+ private static boolean eq(Object o1, Object o2) {
+ return o1 == o2 || o1 != null && o1.equals(o2);
+ }
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = (V)TObjectHash.REMOVED;
+ super.removeAt(index); // clear key, set; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a value <code>array</code>
+ */
+ public Object[] getValues() {
+ Object[] vals = new Object[size()];
+ V[] values = _values;
+
+ for (int i = values.length, j = 0; i-- > 0;) {
+ if (isFull(values, i)) {
+ vals[j++] = unwrapNull(values[i]);
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public int[] keys() {
+ int[] keys = new int[size()];
+ int[] k = _set;
+ Object[] values = _values;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (isFull(values, i)) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(V val) {
+ V[] values = _values;
+
+ // special case null values so that we don't have to
+ // perform null checks before every call to equals()
+ if (null == val) {
+ for (int i = values.length; i-- > 0;) {
+ if (TObjectHash.NULL == values[i]) {
+ return true;
+ }
+ }
+ }
+ else {
+ for (int i = values.length; i-- > 0;) {
+ V value = unwrapNull(values[i]);
+ if (isFull(values, i) && (val == value || val.equals(value))) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>int</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(int key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TIntProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TObjectProcedure<V> procedure) {
+ V[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(unwrapNull(values[i]))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TOIntObjectProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TIntObjectProcedure<V> procedure) {
+ int[] keys = _set;
+ V[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(keys[i],unwrapNull(values[i]))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TIntObjectProcedure<V> procedure) {
+ boolean modified = false;
+ int[] keys = _set;
+ V[] values = _values;
+ stopCompactingOnRemove();
+ try {
+ for (int i = keys.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(keys[i],unwrapNull(values[i]))) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ }
+ finally {
+ startCompactingOnRemove(modified);
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TObjectFunction</code> value
+ */
+ public void transformValues(TObjectFunction<V,V> function) {
+ V[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (isFull(values, i)) {
+ values[i] = wrapNull(function.execute(unwrapNull(values[i])));
+ }
+ }
+ }
+
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ int key = stream.readInt();
+ V val = (V) stream.readObject();
+ put(key, val);
+ }
+ }
+
+ /**
+ * Default implementation of TIntHashingStrategy:
+ * delegates hashing to HashFunctions.hash(int).
+ *
+ * @param val the value to hash
+ * @return the hashcode.
+ */
+ @Override
+ public final int computeHashCode(int val) {
+ return HashFunctions.hash(val);
+ }
+
+} // TIntObjectHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntObjectIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntObjectIterator.java
new file mode 100755
index 0000000..c62e4e0
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntObjectIterator.java
@@ -0,0 +1,168 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.util.ConcurrentModificationException;
+
+/**
+ * Iterator for maps of type int and Object.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TIntObjectIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TIntObjectIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TIntObjectIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TIntObjectIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+public class TIntObjectIterator <V> extends TIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TIntObjectHashMap<V> _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TIntObjectIterator(TIntObjectHashMap<V> map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Returns the index of the next value in the data structure
+ * or a negative value if the iterator is exhausted.
+ *
+ * @return an <code>int</code> value
+ * @exception ConcurrentModificationException if the underlying collection's
+ * size has been modified since the iterator was created.
+ */
+ @Override
+ protected final int nextIndex() {
+ if (_expectedSize != _map.size()) {
+ throw new ConcurrentModificationException();
+ }
+
+ Object[] values = _map._values;
+ int i = _index;
+ while (i-- > 0 && !TIntObjectHashMap.isFull(values, i));
+ return i;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public int key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public V value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public V setValue(V val) {
+ V old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TIntObjectIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntObjectProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntObjectProcedure.java
new file mode 100755
index 0000000..d53d468
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntObjectProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type int and Object.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TIntObjectProcedure<V> {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>int</code> value
+ * @param b an <code>Object</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(int a, V b);
+}// TIntObjectProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntProcedure.java
new file mode 100755
index 0000000..3312456
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntProcedure.java
@@ -0,0 +1,40 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures with one int parameter.
+ *
+ * Created: Mon Nov 5 21:45:49 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TIntProcedure {
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param value a value of type <code>int</code>
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(int value);
+}// TIntProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntStack.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntStack.java
new file mode 100755
index 0000000..95c004a
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIntStack.java
@@ -0,0 +1,126 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+
+package gnu.trove;
+
+/**
+ * A stack of int primitives, backed by a TIntArrayList.
+ *
+ * Created: Tue Jan 1 10:30:35 2002
+ *
+ * @author Eric D. Friedman
+ * @version $Id: TIntStack.java,v 1.5 2004/09/24 09:11:15 cdr Exp $
+ */
+
+public class TIntStack {
+
+ /** the list used to hold the stack values. */
+ protected TIntArrayList _list;
+
+ public static final int DEFAULT_CAPACITY = TIntArrayList.DEFAULT_CAPACITY;
+
+ /**
+ * Creates a new <code>TIntStack</code> instance with the default
+ * capacity.
+ */
+ public TIntStack() {
+ this(DEFAULT_CAPACITY);
+ }
+
+ /**
+ * Copy constructor.
+ * @param copy
+ */
+ public TIntStack(TIntStack copy) {
+ _list = new TIntArrayList(copy._list.toNativeArray());
+ }
+
+ /**
+ * Creates a new <code>TIntStack</code> instance with the
+ * specified capacity.
+ *
+ * @param capacity the initial depth of the stack
+ */
+ public TIntStack(int capacity) {
+ _list = new TIntArrayList(capacity);
+ }
+
+ /**
+ * Pushes the value onto the top of the stack.
+ *
+ * @param val an <code>int</code> value
+ */
+ public void push(int val) {
+ _list.add(val);
+ }
+
+ /**
+ * Removes and returns the value at the top of the stack.
+ *
+ * @return an <code>int</code> value
+ */
+ public int pop() {
+ return _list.remove(_list.size() - 1);
+ }
+
+ /**
+ * Returns the value at the top of the stack.
+ *
+ * @return an <code>int</code> value
+ */
+ public int peek() {
+ return _list.get(_list.size() - 1);
+ }
+
+ /**
+ * Returns the current depth of the stack.
+ *
+ * @return an <code>int</code> value
+ */
+ public int size() {
+ return _list.size();
+ }
+
+ /**
+ * Clears the stack, reseting its capacity to the default.
+ */
+ public void clear() {
+ _list.clear(DEFAULT_CAPACITY);
+ }
+
+ /**
+ * Clears the stack without releasing its internal capacity allocation.
+ */
+ public void reset() {
+ _list.reset();
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof TIntStack)) return false;
+
+ final TIntStack tIntStack = (TIntStack) o;
+
+ return _list.equals(tIntStack._list);
+ }
+
+ public int hashCode() {
+ return _list.hashCode();
+ }
+} // TIntStack
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIterator.java
new file mode 100755
index 0000000..21f2a34
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TIterator.java
@@ -0,0 +1,100 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+import java.util.ConcurrentModificationException;
+import java.util.NoSuchElementException;
+
+/**
+ * Abstract iterator class for THash implementations. This class provides some
+ * of the common iterator operations (hasNext(), remove()) and allows subclasses
+ * to define the mechanism(s) for advancing the iterator and returning data.
+ *
+ * @author Eric D. Friedman
+ * @version $Id: TIterator.java,v 1.6 2004/09/24 09:11:15 cdr Exp $
+ */
+abstract class TIterator {
+ /** the data structure this iterator traverses */
+ protected final THash _hash;
+ /** the number of elements this iterator believes are in the
+ * data structure it accesses. */
+ protected int _expectedSize;
+ /** the index used for iteration. */
+ protected int _index;
+
+ /**
+ * Create an instance of TIterator over the specified THash.
+ */
+ public TIterator(THash hash) {
+ _hash = hash;
+ _expectedSize = _hash.size();
+ _index = _hash.capacity();
+ }
+
+ /**
+ * Returns true if the iterator can be advanced past its current
+ * location.
+ *
+ * @return a <code>boolean</code> value
+ */
+ public boolean hasNext() {
+ return nextIndex() >= 0;
+ }
+
+ /**
+ * Removes the last entry returned by the iterator.
+ * Invoking this method more than once for a single entry
+ * will leave the underlying data structure in a confused
+ * state.
+ */
+ public void remove() {
+ if (_expectedSize != _hash.size()) {
+ throw new ConcurrentModificationException();
+ }
+
+ _hash.stopCompactingOnRemove();
+ try {
+ _hash.removeAt(_index);
+ } finally {
+ _hash.startCompactingOnRemove(false);
+ }
+
+ _expectedSize--;
+ }
+
+ /**
+ * Sets the internal <tt>index</tt> so that the `next' object
+ * can be returned.
+ */
+ protected final void moveToNextIndex() {
+ // doing the assignment && < 0 in one line shaves
+ // 3 opcodes...
+ if ((_index = nextIndex()) < 0) {
+ throw new NoSuchElementException();
+ }
+ }
+
+ /**
+ * Returns the index of the next value in the data structure
+ * or a negative value if the iterator is exhausted.
+ *
+ * @return an <code>int</code> value
+ */
+ protected abstract int nextIndex();
+} // TIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLinkable.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLinkable.java
new file mode 100755
index 0000000..af58eba
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLinkable.java
@@ -0,0 +1,65 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+import java.io.Serializable;
+
+
+/**
+ * Interface for Objects which can be inserted into a TLinkedList.
+ *
+ * <p>
+ * Created: Sat Nov 10 15:23:41 2001
+ * </p>
+ *
+ * @author Eric D. Friedman
+ * @version $Id: TLinkable.java,v 1.8 2004/09/24 09:11:15 cdr Exp $
+ * @see TLinkedList
+ */
+
+public interface TLinkable extends Serializable {
+
+ /**
+ * Returns the linked list node after this one.
+ *
+ * @return a <code>TLinkable</code> value
+ */
+ TLinkable getNext();
+
+ /**
+ * Returns the linked list node before this one.
+ *
+ * @return a <code>TLinkable</code> value
+ */
+ TLinkable getPrevious();
+
+ /**
+ * Sets the linked list node after this one.
+ *
+ * @param linkable a <code>TLinkable</code> value
+ */
+ void setNext(TLinkable linkable);
+
+ /**
+ * Sets the linked list node before this one.
+ *
+ * @param linkable a <code>TLinkable</code> value
+ */
+ void setPrevious(TLinkable linkable);
+}// TLinkable
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLinkableAdaptor.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLinkableAdaptor.java
new file mode 100755
index 0000000..c00f6a8
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLinkableAdaptor.java
@@ -0,0 +1,79 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Jason Baldridge All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+/**
+ * Adapter for TLinkable interface which implements the interface and can
+ * therefore be extended trivially to create TLinkable objects without
+ * having to implement the obvious.
+ *
+ * <p>
+ * Created: Thurs Nov 15 16:25:00 2001
+ * </p>
+ *
+ * @author Jason Baldridge
+ * @version $Id: TLinkableAdaptor.java,v 1.8 2004/09/24 09:11:15 cdr Exp $
+ * @see TLinkedList
+ */
+
+public class TLinkableAdaptor implements TLinkable {
+ TLinkable _previous;
+ TLinkable _next;
+
+ /**
+ * Returns the linked list node after this one.
+ *
+ * @return a <code>TLinkable</code> value
+ */
+ @Override
+ public TLinkable getNext() {
+ return _next;
+ }
+
+ /**
+ * Returns the linked list node before this one.
+ *
+ * @return a <code>TLinkable</code> value
+ */
+ @Override
+ public TLinkable getPrevious() {
+ return _previous;
+ }
+
+ /**
+ * Sets the linked list node after this one.
+ *
+ * @param linkable a <code>TLinkable</code> value
+ */
+ @Override
+ public void setNext(TLinkable linkable) {
+ _next = linkable;
+ }
+
+ /**
+ * Sets the linked list node before this one.
+ *
+ * @param linkable a <code>TLinkable</code> value
+ */
+ @Override
+ public void setPrevious(TLinkable linkable) {
+ _previous = linkable;
+ }
+
+}
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLinkedList.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLinkedList.java
new file mode 100755
index 0000000..70ab317
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLinkedList.java
@@ -0,0 +1,614 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+
+package gnu.trove;
+
+import java.io.Serializable;
+import java.util.AbstractSequentialList;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
+
+/**
+ * A LinkedList implementation which holds instances of type
+ * <tt>TLinkable</tt>.
+ *
+ * <p>Using this implementation allows you to get java.util.LinkedList
+ * behavior (a doubly linked list, with Iterators that support insert
+ * and delete operations) without incurring the overhead of creating
+ * <tt>Node</tt> wrapper objects for every element in your list.</p>
+ *
+ * <p>The requirement to achieve this time/space gain is that the
+ * Objects stored in the List implement the <tt>TLinkable</tt>
+ * interface.</p>
+ *
+ * <p>The limitations are that you cannot put the same object into
+ * more than one list or more than once in the same list. You must
+ * also ensure that you only remove objects that are actually in the
+ * list. That is, if you have an object A and lists l1 and l2, you
+ * must ensure that you invoke List.remove(A) on the correct list. It
+ * is also forbidden to invoke List.remove() with an unaffiliated
+ * TLinkable (one that belongs to no list): this will destroy the list
+ * you invoke it on.</p>
+ *
+ * <p>
+ * Created: Sat Nov 10 15:25:10 2001
+ * </p>
+ *
+ * @author Eric D. Friedman
+ * @version $Id: TLinkedList.java,v 1.5 2004/09/24 09:11:15 cdr Exp $
+ * @see TLinkable
+ */
+
+public class TLinkedList<T extends TLinkable> extends AbstractSequentialList<T> implements Serializable {
+
+ /** the head of the list */
+ protected T _head;
+ /** the tail of the list */
+ protected T _tail;
+ /** the number of elements in the list */
+ protected int _size;
+
+ /**
+ * Creates a new <code>TLinkedList</code> instance.
+ *
+ */
+ public TLinkedList() {
+ super();
+ }
+
+ /**
+ * Returns an iterator positioned at <tt>index</tt>. Assuming
+ * that the list has a value at that index, calling next() will
+ * retrieve and advance the iterator. Assuming that there is a
+ * value before <tt>index</tt> in the list, calling previous()
+ * will retrieve it (the value at index - 1) and move the iterator
+ * to that position. So, iterating from front to back starts at
+ * 0; iterating from back to front starts at <tt>size()</tt>.
+ *
+ * @param index an <code>int</code> value
+ * @return a <code>ListIterator</code> value
+ */
+ @Override
+ public ListIterator<T> listIterator(int index) {
+ return new IteratorImpl(index);
+ }
+
+ /**
+ * Returns the number of elements in the list.
+ *
+ * @return an <code>int</code> value
+ */
+ @Override
+ public int size() {
+ return _size;
+ }
+
+ /**
+ * Inserts <tt>linkable</tt> at index <tt>index</tt> in the list.
+ * All values > index are shifted over one position to accomodate
+ * the new addition.
+ *
+ * @param index an <code>int</code> value
+ * @param linkable an object of type TLinkable
+ */
+ @Override
+ public void add(int index, T linkable) {
+ if (index < 0 || index > size()) {
+ throw new IndexOutOfBoundsException("index:" + index);
+ }
+ insert(index,linkable);
+ }
+
+ /**
+ * Appends <tt>linkable</tt> to the end of the list.
+ *
+ * @param linkable an object of type TLinkable
+ * @return always true
+ */
+ @Override
+ public boolean add(T linkable) {
+ insert(_size, linkable);
+ return true;
+ }
+
+ /**
+ * Inserts <tt>linkable</tt> at the head of the list.
+ *
+ * @param linkable an object of type TLinkable
+ */
+ public void addFirst(T linkable) {
+ insert(0, linkable);
+ }
+
+ /**
+ * Adds <tt>linkable</tt> to the end of the list.
+ *
+ * @param linkable an object of type TLinkable
+ */
+ public void addLast(T linkable) {
+ insert(size(), linkable);
+ }
+
+ /**
+ * Empties the list.
+ *
+ */
+ @Override
+ public void clear() {
+ if (null != _head) {
+ for (TLinkable link = _head.getNext();
+ link != null;
+ link = link.getNext()) {
+ TLinkable prev = link.getPrevious();
+ prev.setNext(null);
+ link.setPrevious(null);
+ }
+ _head = _tail = null;
+ }
+ _size = 0;
+ }
+
+ /**
+ * Copies the list's contents into a native array. This will be a
+ * shallow copy: the Tlinkable instances in the Object[] array
+ * have links to one another: changing those will put this list
+ * into an unpredictable state. Holding a reference to one
+ * element in the list will prevent the others from being garbage
+ * collected unless you clear the next/previous links. <b>Caveat
+ * programmer!</b>
+ *
+ * @return an <code>Object[]</code> value
+ */
+ @Override
+ public Object[] toArray() {
+ Object[] o = new Object[_size];
+ int i = 0;
+ for (TLinkable link = _head; link != null; link = link.getNext()) {
+ o[i++] = link;
+ }
+ return o;
+ }
+
+ /**
+ * Copies the list to a native array, destroying the next/previous
+ * links as the copy is made. This list will be emptied after the
+ * copy (as if clear() had been invoked). The Object[] array
+ * returned will contain TLinkables that do <b>not</b> hold
+ * references to one another and so are less likely to be the
+ * cause of memory leaks.
+ *
+ * @return an <code>Object[]</code> value
+ */
+ public Object[] toUnlinkedArray() {
+ Object[] o = new Object[_size];
+ int i = 0;
+ for (T link = _head; link != null; i++) {
+ o[i] = link;
+ T tmp = link;
+ link = (T) link.getNext();
+ tmp.setNext(null); // clear the links
+ tmp.setPrevious(null);
+ }
+ _size = 0; // clear the list
+ _head = _tail = null;
+ return o;
+ }
+
+ /**
+ * A linear search for <tt>o</tt> in the list.
+ *
+ * @param o an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean contains(Object o) {
+ for (TLinkable link = _head; link != null; link = link.getNext()) {
+ if (o.equals(link)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns the head of the list
+ *
+ * @return an <code>Object</code> value
+ */
+ public T getFirst() {
+ return _head;
+ }
+
+ /**
+ * Returns the tail of the list.
+ *
+ * @return an <code>Object</code> value
+ */
+ public T getLast() {
+ return _tail;
+ }
+
+ /**
+ * Remove and return the first element in the list.
+ *
+ * @return an <code>Object</code> value
+ */
+ public T removeFirst() {
+ T o = _head;
+ T n = (T) o.getNext();
+ o.setNext(null);
+
+ if (null != n) {
+ n.setPrevious(null);
+ }
+
+ _head = n;
+ if (--_size == 0) {
+ _tail = null;
+ }
+ return o;
+ }
+
+ /**
+ * Remove and return the last element in the list.
+ *
+ * @return an <code>Object</code> value
+ */
+ public T removeLast() {
+ T o = _tail;
+ T prev = (T) o.getPrevious();
+ o.setPrevious(null);
+
+ if (null != prev) {
+ prev.setNext(null);
+ }
+ _tail = prev;
+ if (--_size == 0) {
+ _head = null;
+ }
+ return o;
+ }
+
+ /**
+ * Implementation of index-based list insertions.
+ *
+ * @param index an <code>int</code> value
+ * @param linkable an object of type TLinkable
+ */
+ protected void insert(int index, T linkable) {
+ T newLink = linkable;
+
+ if (_size == 0) {
+ _head = _tail = newLink; // first insertion
+ } else if (index == 0) {
+ newLink.setNext(_head); // insert at front
+ _head.setPrevious(newLink);
+ _head = newLink;
+ } else if (index == _size) { // insert at back
+ _tail.setNext(newLink);
+ newLink.setPrevious(_tail);
+ _tail = newLink;
+ } else {
+ TLinkable prior;
+
+ // looking at the size of the list, we decide whether
+ // it's faster to reach `index' by traversing the
+ // list from the front or the back.
+ if (index > (_size >> 1)) { // insert in 2nd half
+ // work from the tail
+ int pos = _size -1;
+ for (prior = _tail; pos > index; pos--) {
+ prior = prior.getPrevious();
+ }
+ } else { // insert in 1st half
+ // work from the head
+ int pos = 0;
+ for (prior = _head; pos < index; pos++) {
+ prior = prior.getNext();
+ }
+ }
+ TLinkable post = prior.getNext();
+ // insert newlink
+ newLink.setNext(post);
+ newLink.setPrevious(prior);
+ // adjust adjacent pointers
+ post.setPrevious(newLink);
+ prior.setNext(newLink);
+ }
+ _size++;
+ }
+
+ /**
+ * Removes the specified element from the list. Note that
+ * it is the caller's responsibility to ensure that the
+ * element does, in fact, belong to this list and not another
+ * instance of TLinkedList.
+ *
+ * @param o a TLinkable element already inserted in this list.
+ * @return true if the element was a TLinkable and removed
+ */
+ @Override
+ public boolean remove(Object o) {
+ if (o instanceof TLinkable) {
+ TLinkable link = (TLinkable)o;
+
+ T p = (T) link.getPrevious();
+ T n = (T) link.getNext();
+
+ if (n == null && p == null) { // emptying the list
+ _head = _tail = null;
+ } else if (n == null) { // this is the tail
+ // make previous the new tail
+ link.setPrevious(null);
+ p.setNext(null);
+ _tail = p;
+ } else if (p == null) { // this is the head
+ // make next the new head
+ link.setNext(null);
+ n.setPrevious(null);
+ _head = n;
+ } else { // somewhere in the middle
+ p.setNext(n);
+ n.setPrevious(p);
+ link.setNext(null);
+ link.setPrevious(null);
+ }
+
+ _size--; // reduce size of list
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Inserts newElement into the list immediately before current.
+ * All elements to the right of and including current are shifted
+ * over.
+ *
+ * @param current a <code>TLinkable</code> value currently in the list.
+ * @param newElement a <code>TLinkable</code> value to be added to
+ * the list.
+ */
+ public void addBefore(T current, T newElement) {
+ if (current == _head) {
+ addFirst(newElement);
+ } else if (current == null) {
+ addLast(newElement);
+ } else {
+ TLinkable p = current.getPrevious();
+ newElement.setNext(current);
+ p.setNext(newElement);
+ newElement.setPrevious(p);
+ current.setPrevious(newElement);
+ _size++;
+ }
+ }
+
+ /**
+ * A ListIterator that supports additions and deletions.
+ *
+ */
+ protected final class IteratorImpl implements ListIterator<T> {
+ private int _nextIndex;
+ private T _next;
+ private T _lastReturned;
+
+ /**
+ * Creates a new <code>Iterator</code> instance positioned at
+ * <tt>index</tt>.
+ *
+ * @param position an <code>int</code> value
+ */
+ IteratorImpl(int position) {
+ if (position < 0 || position > _size) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ _nextIndex = position;
+ if (position == 0) {
+ _next = _head;
+ } else if (position == _size) {
+ _next = null;
+ } else if (position < (_size >> 1)) {
+ int pos = 0;
+ for (_next = _head; pos < position; pos++) {
+ _next = (T) _next.getNext();
+ }
+ } else {
+ int pos = _size - 1;
+ for (_next = _tail; pos > position; pos--) {
+ _next = (T) _next.getPrevious();
+ }
+ }
+ }
+
+ /**
+ * Insert <tt>linkable</tt> at the current position of the iterator.
+ * Calling next() after add() will return the added object.
+ *
+ * @param linkable an object of type TLinkable
+ */
+ @Override
+ public final void add(T linkable) {
+ _lastReturned = null;
+ _nextIndex++;
+
+ if (_size == 0) {
+ TLinkedList.this.add(linkable);
+ } else {
+ addBefore(_next, linkable);
+ }
+ }
+
+ /**
+ * True if a call to next() will return an object.
+ *
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public final boolean hasNext() {
+ return _nextIndex != _size;
+ }
+
+ /**
+ * True if a call to previous() will return a value.
+ *
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public final boolean hasPrevious() {
+ return _nextIndex != 0;
+ }
+
+ /**
+ * Returns the value at the Iterator's index and advances the
+ * iterator.
+ *
+ * @return an <code>Object</code> value
+ * @exception NoSuchElementException if there is no next element
+ */
+ @Override
+ public final T next() {
+ if (_nextIndex == _size) {
+ throw new NoSuchElementException();
+ }
+
+ _lastReturned = _next;
+ _next = (T) _next.getNext();
+ _nextIndex++;
+ return _lastReturned;
+ }
+
+ /**
+ * returns the index of the next node in the list (the
+ * one that would be returned by a call to next()).
+ *
+ * @return an <code>int</code> value
+ */
+ @Override
+ public final int nextIndex() {
+ return _nextIndex;
+ }
+
+ /**
+ * Returns the value before the Iterator's index and moves the
+ * iterator back one index.
+ *
+ * @return an <code>Object</code> value
+ * @exception NoSuchElementException if there is no previous element.
+ */
+ @Override
+ public final T previous() {
+ if (_nextIndex == 0) {
+ throw new NoSuchElementException();
+ }
+
+ if (_nextIndex == _size) {
+ _lastReturned = _next = _tail;
+ } else {
+ _lastReturned = _next = (T) _next.getPrevious();
+ }
+
+ _nextIndex--;
+ return _lastReturned;
+ }
+
+ /**
+ * Returns the previous element's index.
+ *
+ * @return an <code>int</code> value
+ */
+ @Override
+ public final int previousIndex() {
+ return _nextIndex - 1;
+ }
+
+ /**
+ * Removes the current element in the list and shrinks its
+ * size accordingly.
+ *
+ * @exception IllegalStateException neither next nor previous
+ * have been invoked, or remove or add have been invoked after
+ * the last invocation of next or previous.
+ */
+ @Override
+ public final void remove() {
+ if (_lastReturned == null) {
+ throw new IllegalStateException("must invoke next or previous before invoking remove");
+ }
+
+ if (_lastReturned != _next) {
+ _nextIndex--;
+ }
+ _next = (T) _lastReturned.getNext();
+ TLinkedList.this.remove(_lastReturned);
+ _lastReturned = null;
+ }
+
+ /**
+ * Replaces the current element in the list with
+ * <tt>linkable</tt>
+ *
+ * @param linkable an object of type TLinkable
+ */
+ @Override
+ public final void set(T linkable) {
+ if (_lastReturned == null) {
+ throw new IllegalStateException();
+ }
+ T l = linkable;
+
+ // need to check both, since this could be the only
+ // element in the list.
+ if (_lastReturned == _head) {
+ _head = l;
+ }
+
+ if (_lastReturned == _tail) {
+ _tail = l;
+ }
+
+ swap(_lastReturned, l);
+ _lastReturned = l;
+ }
+
+ /**
+ * Replace from with to in the list.
+ *
+ * @param from a <code>TLinkable</code> value
+ * @param to a <code>TLinkable</code> value
+ */
+ private void swap(T from, T to) {
+ T p = (T) from.getPrevious();
+ T n = (T) from.getNext();
+
+ if (null != p) {
+ to.setPrevious(p);
+ p.setNext(to);
+ }
+ if (null != n) {
+ to.setNext(n);
+ n.setPrevious(to);
+ }
+ from.setNext(null);
+ from.setPrevious(null);
+ }
+ }
+} // TLinkedList
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongArrayList.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongArrayList.java
new file mode 100755
index 0000000..d3e638d
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongArrayList.java
@@ -0,0 +1,889 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Random;
+
+/**
+ * A resizable, array-backed list of long primitives.
+ *
+ * Created: Sat Dec 29 14:21:12 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TLongArrayList implements Serializable, Cloneable {
+
+ /** the data of the list */
+ protected transient long[] _data;
+
+ /** the index after the last entry in the list */
+ protected transient int _pos;
+
+ /** the default capacity for new lists */
+ protected static final int DEFAULT_CAPACITY = 4;
+
+ /**
+ * Creates a new <code>TLongArrayList</code> instance with the
+ * default capacity.
+ */
+ public TLongArrayList() {
+ this(DEFAULT_CAPACITY);
+ }
+
+ /**
+ * Creates a new <code>TLongArrayList</code> instance with the
+ * specified capacity.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ public TLongArrayList(int capacity) {
+ _data = new long[capacity];
+ _pos = 0;
+ }
+
+ /**
+ * Creates a new <code>TLongArrayList</code> instance whose
+ * capacity is the greater of the length of <tt>values</tt> and
+ * DEFAULT_CAPACITY and whose initial contents are the specified
+ * values.
+ *
+ * @param values an <code>long[]</code> value
+ */
+ public TLongArrayList(long[] values) {
+ this(Math.max(values.length, DEFAULT_CAPACITY));
+ add(values);
+ }
+
+ // sizing
+
+ /**
+ * Grow the internal array as needed to accomodate the specified
+ * number of elements. The size of the array doubles on each
+ * resize unless <tt>capacity</tt> requires more than twice the
+ * current capacity.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ public void ensureCapacity(int capacity) {
+ if (capacity > _data.length) {
+ int newCap = Math.max(_data.length << 1, capacity);
+ long[] tmp = new long[newCap];
+ System.arraycopy(_data, 0, tmp, 0, _data.length);
+ _data = tmp;
+ }
+ }
+
+ /**
+ * Returns the number of values in the list.
+ *
+ * @return the number of values in the list.
+ */
+ public int size() {
+ return _pos;
+ }
+
+ /**
+ * Tests whether this list contains any values.
+ *
+ * @return true if the list is empty.
+ */
+ public boolean isEmpty() {
+ return _pos == 0;
+ }
+
+ /**
+ * Sheds any excess capacity above and beyond the current size of
+ * the list.
+ */
+ public void trimToSize() {
+ if (_data.length > size()) {
+ long[] tmp = new long[size()];
+ toNativeArray(tmp, 0, tmp.length);
+ _data = tmp;
+ }
+ }
+
+ // modifying
+
+ /**
+ * Adds <tt>val</tt> to the end of the list, growing as needed.
+ *
+ * @param val an <code>long</code> value
+ */
+ public void add(long val) {
+ ensureCapacity(_pos + 1);
+ _data[_pos++] = val;
+ }
+
+ /**
+ * Adds the values in the array <tt>vals</tt> to the end of the
+ * list, in order.
+ *
+ * @param vals an <code>long[]</code> value
+ */
+ public void add(long[] vals) {
+ add(vals, 0, vals.length);
+ }
+
+ /**
+ * Adds a subset of the values in the array <tt>vals</tt> to the
+ * end of the list, in order.
+ *
+ * @param vals an <code>long[]</code> value
+ * @param offset the offset at which to start copying
+ * @param length the number of values to copy.
+ */
+ public void add(long[] vals, int offset, int length) {
+ ensureCapacity(_pos + length);
+ System.arraycopy(vals, offset, _data, _pos, length);
+ _pos += length;
+ }
+
+ /**
+ * Inserts <tt>value</tt> into the list at <tt>offset</tt>. All
+ * values including and to the right of <tt>offset</tt> are shifted
+ * to the right.
+ *
+ * @param offset an <code>int</code> value
+ * @param value an <code>long</code> value
+ */
+ public void insert(int offset, long value) {
+ if (offset == _pos) {
+ add(value);
+ return;
+ }
+ ensureCapacity(_pos + 1);
+ // shift right
+ System.arraycopy(_data, offset, _data, offset + 1, _pos - offset);
+ // insert
+ _data[offset] = value;
+ _pos++;
+ }
+
+ /**
+ * Inserts the array of <tt>values</tt> into the list at
+ * <tt>offset</tt>. All values including and to the right of
+ * <tt>offset</tt> are shifted to the right.
+ *
+ * @param offset an <code>int</code> value
+ * @param values an <code>long[]</code> value
+ */
+ public void insert(int offset, long[] values) {
+ insert(offset, values, 0, values.length);
+ }
+
+ /**
+ * Inserts a slice of the array of <tt>values</tt> into the list
+ * at <tt>offset</tt>. All values including and to the right of
+ * <tt>offset</tt> are shifted to the right.
+ *
+ * @param offset an <code>int</code> value
+ * @param values an <code>long[]</code> value
+ * @param valOffset the offset in the values array at which to
+ * start copying.
+ * @param len the number of values to copy from the values array
+ */
+ public void insert(int offset, long[] values, int valOffset, int len) {
+ if (offset == _pos) {
+ add(values, valOffset, len);
+ return;
+ }
+
+ ensureCapacity(_pos + len);
+ // shift right
+ System.arraycopy(_data, offset, _data, offset + len, _pos - offset);
+ // insert
+ System.arraycopy(values, valOffset, _data, offset, len);
+ _pos += len;
+ }
+
+ /**
+ * Returns the value at the specified offset.
+ *
+ * @param offset an <code>int</code> value
+ * @return an <code>long</code> value
+ */
+ public long get(int offset) {
+ if (offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ return _data[offset];
+ }
+
+ /**
+ * Returns the value at the specified offset without doing any
+ * bounds checking.
+ *
+ * @param offset an <code>int</code> value
+ * @return an <code>long</code> value
+ */
+ public long getQuick(int offset) {
+ return _data[offset];
+ }
+
+ /**
+ * Sets the value at the specified offset.
+ *
+ * @param offset an <code>int</code> value
+ * @param val an <code>long</code> value
+ */
+ public void set(int offset, long val) {
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ _data[offset] = val;
+ }
+
+ /**
+ * Sets the value at the specified offset and returns the
+ * previously stored value.
+ *
+ * @param offset an <code>int</code> value
+ * @param val an <code>long</code> value
+ * @return the value previously stored at offset.
+ */
+ public long getSet(int offset, long val) {
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ long old = _data[offset];
+ _data[offset] = val;
+ return old;
+ }
+
+ /**
+ * Replace the values in the list starting at <tt>offset</tt> with
+ * the contents of the <tt>values</tt> array.
+ *
+ * @param offset the first offset to replace
+ * @param values the source of the new values
+ */
+ public void set(int offset, long[] values) {
+ set(offset, values, 0, values.length);
+ }
+
+ /**
+ * Replace the values in the list starting at <tt>offset</tt> with
+ * <tt>length</tt> values from the <tt>values</tt> array, starting
+ * at valOffset.
+ *
+ * @param offset the first offset to replace
+ * @param values the source of the new values
+ * @param valOffset the first value to copy from the values array
+ * @param length the number of values to copy
+ */
+ public void set(int offset, long[] values, int valOffset, int length) {
+ if (offset < 0 || offset + length > _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ System.arraycopy(_data, offset, values, valOffset, length);
+ }
+
+ /**
+ * Sets the value at the specified offset without doing any bounds
+ * checking.
+ *
+ * @param offset an <code>int</code> value
+ * @param val an <code>long</code> value
+ */
+ public void setQuick(int offset, long val) {
+ _data[offset] = val;
+ }
+
+ /**
+ * Flushes the internal state of the list, resetting the capacity
+ * to the default.
+ */
+ public void clear() {
+ clear(DEFAULT_CAPACITY);
+ }
+
+ /**
+ * Flushes the internal state of the list, setting the capacity of
+ * the empty list to <tt>capacity</tt>.
+ *
+ * @param capacity an <code>int</code> value
+ */
+ public void clear(int capacity) {
+ _data = new long[capacity];
+ _pos = 0;
+ }
+
+ /**
+ * Sets the size of the list to 0, but does not change its
+ * capacity. This method can be used as an alternative to the
+ * {@link #clear clear} method if you want to recyle a list without
+ * allocating new backing arrays.
+ *
+ * @see #clear
+ */
+ public void reset() {
+ _pos = 0;
+ fill(0);
+ }
+
+ /**
+ * Sets the size of the list to 0, but does not change its
+ * capacity. This method can be used as an alternative to the
+ * {@link #clear clear} method if you want to recyle a list
+ * without allocating new backing arrays. This method differs
+ * from {@link #reset reset} in that it does not clear the old
+ * values in the backing array. Thus, it is possible for {@link
+ * #getQuick getQuick} to return stale data if this method is used
+ * and the caller is careless about bounds checking.
+ *
+ * @see #reset
+ * @see #clear
+ * @see #getQuick
+ */
+ public void resetQuick() {
+ _pos = 0;
+ }
+
+ /**
+ * Removes the value at <tt>offset</tt> from the list.
+ *
+ * @param offset an <code>int</code> value
+ * @return the value previously stored at offset.
+ */
+ public long remove(int offset) {
+ long old = get(offset);
+ remove(offset, 1);
+ return old;
+ }
+
+ /**
+ * Removes <tt>length</tt> values from the list, starting at
+ * <tt>offset</tt>
+ *
+ * @param offset an <code>int</code> value
+ * @param length an <code>int</code> value
+ */
+ public void remove(int offset, int length) {
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+
+ if (offset == 0) {
+ // data at the front
+ System.arraycopy(_data, length, _data, 0, _pos - length);
+ } else if (_pos - length == offset) {
+ // no copy to make, decrementing pos "deletes" values at
+ // the end
+ } else {
+ // data in the middle
+ System.arraycopy(_data, offset + length,
+ _data, offset, _pos - (offset + length));
+ }
+ _pos -= length;
+ // no need to clear old values beyond _pos, because this is a
+ // primitive collection and 0 takes as much room as any other
+ // value
+ }
+
+ /**
+ * Transform each value in the list using the specified function.
+ *
+ * @param function a <code>TLongFunction</code> value
+ */
+ public void transformValues(TLongFunction function) {
+ for (int i = _pos; i-- > 0;) {
+ _data[i] = function.execute(_data[i]);
+ }
+ }
+
+ /**
+ * Reverse the order of the elements in the list.
+ */
+ public void reverse() {
+ reverse(0, _pos);
+ }
+
+ /**
+ * Reverse the order of the elements in the range of the list.
+ *
+ * @param from the inclusive index at which to start reversing
+ * @param to the exclusive index at which to stop reversing
+ */
+ public void reverse(int from, int to) {
+ if (from == to) {
+ return; // nothing to do
+ }
+ if (from > to) {
+ throw new IllegalArgumentException("from cannot be greater than to");
+ }
+ for (int i = from, j = to - 1; i < j; i++, j--) {
+ swap(i, j);
+ }
+ }
+
+ /**
+ * Shuffle the elements of the list using the specified random
+ * number generator.
+ *
+ * @param rand a <code>Random</code> value
+ */
+ public void shuffle(Random rand) {
+ for (int i = _pos; i-- > 1;) {
+ swap(i, rand.nextInt(i));
+ }
+ }
+
+ /**
+ * Swap the values at offsets <tt>i</tt> and <tt>j</tt>.
+ *
+ * @param i an offset into the data array
+ * @param j an offset into the data array
+ */
+ private void swap(int i, int j) {
+ long tmp = _data[i];
+ _data[i] = _data[j];
+ _data[j] = tmp;
+ }
+
+ // copying
+
+ /**
+ * Returns a clone of this list. Since this is a primitive
+ * collection, this will be a deep clone.
+ *
+ * @return a deep clone of the list.
+ */
+ @Override
+ public Object clone() {
+ TLongArrayList clone = null;
+ try {
+ clone = (TLongArrayList)super.clone();
+ clone._data = _data.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ // it's supported
+ } // end of try-catch
+ return clone;
+ }
+
+ /**
+ * Copies the contents of the list into a native array.
+ *
+ * @return an <code>long[]</code> value
+ */
+ public long[] toNativeArray() {
+ return toNativeArray(0, _pos);
+ }
+
+ /**
+ * Copies a slice of the list into a native array.
+ *
+ * @param offset the offset at which to start copying
+ * @param len the number of values to copy.
+ * @return an <code>long[]</code> value
+ */
+ public long[] toNativeArray(int offset, int len) {
+ long[] rv = new long[len];
+ toNativeArray(rv, offset, len);
+ return rv;
+ }
+
+ /**
+ * Copies a slice of the list into a native array.
+ *
+ * @param dest the array to copy into.
+ * @param offset the offset of the first value to copy
+ * @param len the number of values to copy.
+ */
+ public void toNativeArray(long[] dest, int offset, int len) {
+ if (len == 0) {
+ return; // nothing to copy
+ }
+ if (offset < 0 || offset >= _pos) {
+ throw new ArrayIndexOutOfBoundsException(offset);
+ }
+ System.arraycopy(_data, offset, dest, 0, len);
+ }
+
+ // comparing
+
+ /**
+ * Compares this list to another list, value by value.
+ *
+ * @param other the object to compare against
+ * @return true if other is a TLongArrayList and has exactly the
+ * same values.
+ */
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ } else if (other instanceof TLongArrayList) {
+ TLongArrayList that = (TLongArrayList)other;
+ if (that.size() != this.size()) {
+ return false;
+ } else {
+ for (int i = _pos; i-- > 0;) {
+ if (this._data[i] != that._data[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ int h = 0;
+ for (int i = _pos; i-- > 0;) {
+ h += HashFunctions.hash(_data[i]);
+ }
+ return h;
+ }
+
+ // procedures
+
+ /**
+ * Applies the procedure to each value in the list in ascending
+ * (front to back) order.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return true if the procedure did not terminate prematurely.
+ */
+ public boolean forEach(TLongProcedure procedure) {
+ for (int i = 0; i < _pos; i++) {
+ if (! procedure.execute(_data[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Applies the procedure to each value in the list in descending
+ * (back to front) order.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return true if the procedure did not terminate prematurely.
+ */
+ public boolean forEachDescending(TLongProcedure procedure) {
+ for (int i = _pos; i-- > 0;) {
+ if (! procedure.execute(_data[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // sorting
+
+ /**
+ * Sort the values in the list (ascending) using the Sun quicksort
+ * implementation.
+ *
+ * @see java.util.Arrays#sort
+ */
+ public void sort() {
+ Arrays.sort(_data, 0, _pos);
+ }
+
+ /**
+ * Sort a slice of the list (ascending) using the Sun quicksort
+ * implementation.
+ *
+ * @param fromIndex the index at which to start sorting (inclusive)
+ * @param toIndex the index at which to stop sorting (exclusive)
+ * @see java.util.Arrays#sort
+ */
+ public void sort(int fromIndex, int toIndex) {
+ Arrays.sort(_data, fromIndex, toIndex);
+ }
+
+ // filling
+
+ /**
+ * Fills every slot in the list with the specified value.
+ *
+ * @param val the value to use when filling
+ */
+ public void fill(long val) {
+ Arrays.fill(_data, 0, _pos, val);
+ }
+
+ /**
+ * Fills a range in the list with the specified value.
+ *
+ * @param fromIndex the offset at which to start filling (inclusive)
+ * @param toIndex the offset at which to stop filling (exclusive)
+ * @param val the value to use when filling
+ */
+ public void fill(int fromIndex, int toIndex, long val) {
+ if (toIndex > _pos) {
+ ensureCapacity(toIndex);
+ _pos = toIndex;
+ }
+ Arrays.fill(_data, fromIndex, toIndex, val);
+ }
+
+ // searching
+
+ /**
+ * Performs a binary search for <tt>value</tt> in the entire list.
+ * Note that you <b>must</b> {@link #sort sort} the list before
+ * doing a search.
+ *
+ * @param value the value to search for
+ * @return the absolute offset in the list of the value, or its
+ * negative insertion point into the sorted list.
+ */
+ public int binarySearch(long value) {
+ return binarySearch(value, 0, _pos);
+ }
+
+ /**
+ * Performs a binary search for <tt>value</tt> in the specified
+ * range. Note that you <b>must</b> {@link #sort sort} the list
+ * or the range before doing a search.
+ *
+ * @param value the value to search for
+ * @param fromIndex the lower boundary of the range (inclusive)
+ * @param toIndex the upper boundary of the range (exclusive)
+ * @return the absolute offset in the list of the value, or its
+ * negative insertion point into the sorted list.
+ */
+ public int binarySearch(long value, int fromIndex, int toIndex) {
+ if (fromIndex < 0) {
+ throw new ArrayIndexOutOfBoundsException(fromIndex);
+ }
+ if (toIndex > _pos) {
+ throw new ArrayIndexOutOfBoundsException(toIndex);
+ }
+
+ int low = fromIndex;
+ int high = toIndex - 1;
+
+ while (low <= high) {
+ int mid = (low + high) >> 1;
+ long midVal = _data[mid];
+
+ if (midVal < value) {
+ low = mid + 1;
+ } else if (midVal > value) {
+ high = mid - 1;
+ } else {
+ return mid; // value found
+ }
+ }
+ return -(low + 1); // value not found.
+ }
+
+ /**
+ * Searches the list front to back for the index of
+ * <tt>value</tt>.
+ *
+ * @param value an <code>long</code> value
+ * @return the first offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int indexOf(long value) {
+ return indexOf(0, value);
+ }
+
+ /**
+ * Searches the list front to back for the index of
+ * <tt>value</tt>, starting at <tt>offset</tt>.
+ *
+ * @param offset the offset at which to start the linear search
+ * (inclusive)
+ * @param value an <code>long</code> value
+ * @return the first offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int indexOf(int offset, long value) {
+ for (int i = offset; i < _pos; i++) {
+ if (_data[i] == value) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Searches the list back to front for the last index of
+ * <tt>value</tt>.
+ *
+ * @param value an <code>long</code> value
+ * @return the last offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int lastIndexOf(long value) {
+ return lastIndexOf(_pos, value);
+ }
+
+ /**
+ * Searches the list back to front for the last index of
+ * <tt>value</tt>, starting at <tt>offset</tt>.
+ *
+ * @param offset the offset at which to start the linear search
+ * (exclusive)
+ * @param value an <code>long</code> value
+ * @return the last offset of the value, or -1 if it is not in
+ * the list.
+ * @see #binarySearch for faster searches on sorted lists
+ */
+ public int lastIndexOf(int offset, long value) {
+ for (int i = offset; i-- > 0;) {
+ if (_data[i] == value) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Searches the list for <tt>value</tt>
+ *
+ * @param value an <code>long</code> value
+ * @return true if value is in the list.
+ */
+ public boolean contains(long value) {
+ return lastIndexOf(value) >= 0;
+ }
+
+ /**
+ * Searches the list for values satisfying <tt>condition</tt> in
+ * the manner of the *nix <tt>grep</tt> utility.
+ *
+ * @param condition a condition to apply to each element in the list
+ * @return a list of values which match the condition.
+ */
+ public TLongArrayList grep(TLongProcedure condition) {
+ TLongArrayList list = new TLongArrayList();
+ for (int i = 0; i < _pos; i++) {
+ if (condition.execute(_data[i])) {
+ list.add(_data[i]);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Searches the list for values which do <b>not</b> satisfy
+ * <tt>condition</tt>. This is akin to *nix <code>grep -v</code>.
+ *
+ * @param condition a condition to apply to each element in the list
+ * @return a list of values which do not match the condition.
+ */
+ public TLongArrayList inverseGrep(TLongProcedure condition) {
+ TLongArrayList list = new TLongArrayList();
+ for (int i = 0; i < _pos; i++) {
+ if (! condition.execute(_data[i])) {
+ list.add(_data[i]);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Finds the maximum value in the list.
+ *
+ * @return the largest value in the list.
+ * @exception IllegalStateException if the list is empty
+ */
+ public long max() {
+ if (size() == 0) {
+ throw new IllegalStateException("cannot find maximum of an empty list");
+ }
+ long max = _data[_pos - 1];
+ for (int i = _pos - 1; i-- > 0;) {
+ max = Math.max(max, _data[_pos]);
+ }
+ return max;
+ }
+
+ /**
+ * Finds the minimum value in the list.
+ *
+ * @return the smallest value in the list.
+ * @exception IllegalStateException if the list is empty
+ */
+ public long min() {
+ if (size() == 0) {
+ throw new IllegalStateException("cannot find minimum of an empty list");
+ }
+ long min = _data[_pos - 1];
+ for (int i = _pos - 1; i-- > 0;) {
+ min = Math.min(min, _data[_pos]);
+ }
+ return min;
+ }
+
+ // stringification
+
+ /**
+ * Returns a String representation of the list, front to back.
+ *
+ * @return a <code>String</code> value
+ */
+ public String toString() {
+ final StringBuffer buf = new StringBuffer("{");
+ forEach(new TLongProcedure() {
+ @Override
+ public boolean execute(long val) {
+ buf.append(val);
+ buf.append(", ");
+ return true;
+ }
+ });
+ buf.append("}");
+ return buf.toString();
+ }
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(size());
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEach(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ _data = new long[size];
+ while (size-- > 0) {
+ long val = stream.readLong();
+ add(val);
+ }
+ }
+
+} // TLongArrayList
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongDoubleHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongDoubleHashMap.java
new file mode 100755
index 0000000..3fc8bb6
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongDoubleHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for long keys and double values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TLongDoubleHashMap extends TLongHash {
+
+ /** the values of the map */
+ protected transient double[] _values;
+
+ /**
+ * Creates a new <code>TLongDoubleHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TLongDoubleHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TLongDoubleHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TLongDoubleHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TLongDoubleHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TLongDoubleHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TLongDoubleHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongDoubleHashMap(TLongHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TLongDoubleHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongDoubleHashMap(int initialCapacity, TLongHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TLongDoubleHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongDoubleHashMap(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TLongDoubleHashMap m = (TLongDoubleHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TLongDoubleIterator with access to this map's keys and values
+ */
+ public TLongDoubleIterator iterator() {
+ return new TLongDoubleIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new double[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>long</code> value
+ * @param value an <code>double</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public double put(long key, double value) {
+ double previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ long[] oldKeys = _set;
+ double[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new long[newCapacity];
+ _values = new double[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ long o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>long</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public double get(long key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ long[] keys = _set;
+ double[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>long</code> value
+ * @return an <code>double</code> value
+ */
+ public double remove(long key) {
+ double prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TLongDoubleHashMap)) {
+ return false;
+ }
+ TLongDoubleHashMap that = (TLongDoubleHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TLongDoubleProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(long key, double value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TLongDoubleProcedure {
+ private final TLongDoubleHashMap _otherMap;
+
+ EqProcedure(TLongDoubleHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(long key, double value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two doubles for equality.
+ */
+ private static boolean eq(double v1, double v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public double[] getValues() {
+ double[] vals = new double[size()];
+ double[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public long[] keys() {
+ long[] keys = new long[size()];
+ long[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>double</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(double val) {
+ byte[] states = _states;
+ double[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>long</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(long key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TLongProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TDoubleProcedure procedure) {
+ byte[] states = _states;
+ double[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TLongDoubleProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TLongDoubleProcedure procedure) {
+ byte[] states = _states;
+ long[] keys = _set;
+ double[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TLongDoubleProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ long[] keys = _set;
+ double[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TDoubleFunction</code> value
+ */
+ public void transformValues(TDoubleFunction function) {
+ byte[] states = _states;
+ double[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(long key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(long key, double amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ long key = stream.readLong();
+ double val = stream.readDouble();
+ put(key, val);
+ }
+ }
+} // TLongDoubleHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongDoubleIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongDoubleIterator.java
new file mode 100755
index 0000000..eb1cae3
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongDoubleIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type long and double.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TLongDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TLongDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TLongDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TLongDoubleIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TLongDoubleIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TLongDoubleHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TLongDoubleIterator(TLongDoubleHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public long key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public double value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public double setValue(double val) {
+ double old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TLongDoubleIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongDoubleProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongDoubleProcedure.java
new file mode 100755
index 0000000..1a67429
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongDoubleProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type long and double.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TLongDoubleProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>long</code> value
+ * @param b an <code>double</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(long a, double b);
+}// TLongDoubleProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongFloatHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongFloatHashMap.java
new file mode 100755
index 0000000..c27a48c
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongFloatHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for long keys and float values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TLongFloatHashMap extends TLongHash {
+
+ /** the values of the map */
+ protected transient float[] _values;
+
+ /**
+ * Creates a new <code>TLongFloatHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TLongFloatHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TLongFloatHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TLongFloatHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TLongFloatHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TLongFloatHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TLongFloatHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongFloatHashMap(TLongHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TLongFloatHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongFloatHashMap(int initialCapacity, TLongHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TLongFloatHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongFloatHashMap(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TLongFloatHashMap m = (TLongFloatHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TLongFloatIterator with access to this map's keys and values
+ */
+ public TLongFloatIterator iterator() {
+ return new TLongFloatIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new float[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>long</code> value
+ * @param value an <code>float</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public float put(long key, float value) {
+ float previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ long[] oldKeys = _set;
+ float[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new long[newCapacity];
+ _values = new float[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ long o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>long</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public float get(long key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ long[] keys = _set;
+ float[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>long</code> value
+ * @return an <code>float</code> value
+ */
+ public float remove(long key) {
+ float prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TLongFloatHashMap)) {
+ return false;
+ }
+ TLongFloatHashMap that = (TLongFloatHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TLongFloatProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(long key, float value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TLongFloatProcedure {
+ private final TLongFloatHashMap _otherMap;
+
+ EqProcedure(TLongFloatHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(long key, float value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two floats for equality.
+ */
+ private static boolean eq(float v1, float v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public float[] getValues() {
+ float[] vals = new float[size()];
+ float[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public long[] keys() {
+ long[] keys = new long[size()];
+ long[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>float</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(float val) {
+ byte[] states = _states;
+ float[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>long</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(long key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TLongProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TFloatProcedure procedure) {
+ byte[] states = _states;
+ float[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TLongFloatProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TLongFloatProcedure procedure) {
+ byte[] states = _states;
+ long[] keys = _set;
+ float[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TLongFloatProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ long[] keys = _set;
+ float[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TFloatFunction</code> value
+ */
+ public void transformValues(TFloatFunction function) {
+ byte[] states = _states;
+ float[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(long key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(long key, float amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ long key = stream.readLong();
+ float val = stream.readFloat();
+ put(key, val);
+ }
+ }
+} // TLongFloatHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongFloatIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongFloatIterator.java
new file mode 100755
index 0000000..7a62729
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongFloatIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type long and float.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TLongFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TLongFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TLongFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TLongFloatIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TLongFloatIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TLongFloatHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TLongFloatIterator(TLongFloatHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public long key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public float value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public float setValue(float val) {
+ float old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TLongFloatIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongFloatProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongFloatProcedure.java
new file mode 100755
index 0000000..350c682
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongFloatProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type long and float.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TLongFloatProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>long</code> value
+ * @param b an <code>float</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(long a, float b);
+}// TLongFloatProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongFunction.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongFunction.java
new file mode 100755
index 0000000..4b33077
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongFunction.java
@@ -0,0 +1,37 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for functions that accept and return one long primitive.
+ *
+ * Created: Mon Nov 5 22:19:36 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TLongFunction {
+ /**
+ * Execute this function with <tt>value</tt>
+ *
+ * @param value an <code>long</code> input
+ * @return an <code>long</code> result
+ */
+ long execute(long value);
+}// TLongFunction
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongHash.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongHash.java
new file mode 100755
index 0000000..d45e034
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongHash.java
@@ -0,0 +1,261 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * An open addressed hashing implementation for long primitives.
+ *
+ * Created: Sun Nov 4 08:56:06 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+abstract public class TLongHash extends TPrimitiveHash
+ implements TLongHashingStrategy {
+
+ /** the set of longs */
+ protected transient long[] _set;
+
+ /** strategy used to hash values in this collection */
+ protected TLongHashingStrategy _hashingStrategy;
+
+ /**
+ * Creates a new <code>TLongHash</code> instance with the default
+ * capacity and load factor.
+ */
+ public TLongHash() {
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TLongHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TLongHash(int initialCapacity) {
+ super(initialCapacity);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TLongHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ */
+ public TLongHash(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TLongHash</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongHash(TLongHashingStrategy strategy) {
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TLongHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongHash(int initialCapacity, TLongHashingStrategy strategy) {
+ super(initialCapacity);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TLongHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongHash(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TLongHash h = (TLongHash)super.clone();
+ h._set = _set.clone();
+ return h;
+ }
+
+ /**
+ * initializes the hash table to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _set = new long[capacity];
+ return capacity;
+ }
+
+ /**
+ * Searches the set for <tt>val</tt>
+ *
+ * @param val an <code>long</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean contains(long val) {
+ return index(val) >= 0;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each element in the set.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the set terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEach(TLongProcedure procedure) {
+ byte[] states = _states;
+ long[] set = _set;
+ for (int i = set.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(set[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Releases the element currently stored at <tt>index</tt>.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _set[index] = (long)0;
+ super.removeAt(index);
+ }
+
+ /**
+ * Locates the index of <tt>val</tt>.
+ *
+ * @param val an <code>long</code> value
+ * @return the index of <tt>val</tt> or -1 if it isn't in the set.
+ */
+ protected int index(long val) {
+ byte[] states = _states;
+ long[] set = _set;
+ int length = states.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (states[index] != FREE &&
+ (states[index] == REMOVED || set[index] != val)) {
+ // see Knuth, p. 529
+ int probe = 1 + (hash % (length - 2));
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ } while (states[index] != FREE &&
+ (states[index] == REMOVED || set[index] != val));
+ }
+
+ return states[index] == FREE ? -1 : index;
+ }
+
+ /**
+ * Locates the index at which <tt>val</tt> can be inserted. if
+ * there is already a value equal()ing <tt>val</tt> in the set,
+ * returns that value as a negative integer.
+ *
+ * @param val an <code>long</code> value
+ * @return an <code>int</code> value
+ */
+ protected int insertionIndex(long val) {
+ byte[] states = _states;
+ long[] set = _set;
+ int length = states.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (states[index] == FREE) {
+ return index; // empty, all done
+ } else if (states[index] == FULL && set[index] == val) {
+ return -index -1; // already stored
+ } else { // already FULL or REMOVED, must probe
+ // compute the double hash
+ int probe = 1 + (hash % (length - 2));
+ // starting at the natural offset, probe until we find an
+ // offset that isn't full.
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ } while (states[index] == FULL && set[index] != val);
+
+ // if the index we found was removed: continue probing until we
+ // locate a free location or an element which equal()s the
+ // one we have.
+ if (states[index] == REMOVED) {
+ int firstRemoved = index;
+ while (states[index] != FREE &&
+ (states[index] == REMOVED || set[index] != val)) {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ }
+ return states[index] == FULL ? -index -1 : firstRemoved;
+ }
+ // if it's full, the key is already stored
+ return states[index] == FULL ? -index -1 : index;
+ }
+ }
+
+ /**
+ * Default implementation of TLongHashingStrategy:
+ * delegates hashing to HashFunctions.hash(long).
+ *
+ * @param val the value to hash
+ * @return the hash code.
+ */
+ @Override
+ public final int computeHashCode(long val) {
+ return HashFunctions.hash(val);
+ }
+} // TLongHash
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongHashSet.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongHashSet.java
new file mode 100755
index 0000000..530cca0
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongHashSet.java
@@ -0,0 +1,363 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Arrays;
+
+/**
+ * An open addressed set implementation for long primitives.
+ *
+ * Created: Sat Nov 3 10:38:17 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TLongHashSet extends TLongHash {
+
+ /**
+ * Creates a new <code>TLongHashSet</code> instance with the default
+ * capacity and load factor.
+ */
+ public TLongHashSet() {
+ }
+
+ /**
+ * Creates a new <code>TLongHashSet</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TLongHashSet(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TLongHashSet</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TLongHashSet(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TLongHashSet</code> instance containing the
+ * elements of <tt>array</tt>.
+ *
+ * @param array an array of <code>long</code> primitives
+ */
+ public TLongHashSet(long[] array) {
+ this(array.length);
+ addAll(array);
+ }
+
+ /**
+ * Creates a new <code>TLongHash</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongHashSet(TLongHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TLongHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongHashSet(int initialCapacity, TLongHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TLongHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongHashSet(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * Creates a new <code>TLongHashSet</code> instance containing the
+ * elements of <tt>array</tt>.
+ *
+ * @param array an array of <code>long</code> primitives
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongHashSet(long[] array, TLongHashingStrategy strategy) {
+ this(array.length, strategy);
+ addAll(array);
+ }
+
+ /**
+ * @return a TLongIterator with access to the values in this set
+ */
+ public TLongIterator iterator() {
+ return new TLongIterator(this);
+ }
+
+ /**
+ * Inserts a value into the set.
+ *
+ * @param val an <code>long</code> value
+ * @return true if the set was modified by the add operation
+ */
+ public boolean add(long val) {
+ int index = insertionIndex(val);
+
+ if (index < 0) {
+ return false; // already present in set, nothing to add
+ }
+
+ byte previousState = _states[index];
+ _set[index] = val;
+ _states[index] = FULL;
+ postInsertHook(previousState == FREE);
+
+ return true; // yes, we added something
+ }
+
+ /**
+ * Expands the set to accommodate new values.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ long[] oldSet = _set;
+ byte[] oldStates = _states;
+
+ _set = new long[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ long o = oldSet[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * Returns a new array containing the values in the set.
+ *
+ * @return an <code>long[]</code> value
+ */
+ public long[] toArray() {
+ long[] result = new long[size()];
+ long[] set = _set;
+ byte[] states = _states;
+
+ for (int i = states.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ result[j++] = set[i];
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Empties the set.
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ long[] set = _set;
+ byte[] states = _states;
+
+ for (int i = set.length; i-- > 0;) {
+ set[i] = (long)0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Compares this set with another set for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TLongHashSet)) {
+ return false;
+ }
+ final TLongHashSet that = (TLongHashSet)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEach(new TLongProcedure() {
+ @Override
+ public final boolean execute(long value) {
+ return that.contains(value);
+ }
+ });
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEach(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TLongProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(long key) {
+ h += _hashingStrategy.computeHashCode(key);
+ return true;
+ }
+ }
+
+ /**
+ * Removes <tt>val</tt> from the set.
+ *
+ * @param val an <code>long</code> value
+ * @return true if the set was modified by the remove operation.
+ */
+ public boolean remove(long val) {
+ int index = index(val);
+ if (index >= 0) {
+ removeAt(index);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Tests the set to determine if all of the elements in
+ * <tt>array</tt> are present.
+ *
+ * @param array an <code>array</code> of long primitives.
+ * @return true if all elements were present in the set.
+ */
+ public boolean containsAll(long[] array) {
+ for (int i = array.length; i-- > 0;) {
+ if (! contains(array[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Adds all of the elements in <tt>array</tt> to the set.
+ *
+ * @param array an <code>array</code> of long primitives.
+ * @return true if the set was modified by the add all operation.
+ */
+ public boolean addAll(long[] array) {
+ boolean changed = false;
+ for (int i = array.length; i-- > 0;) {
+ if (add(array[i])) {
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ /**
+ * Removes all of the elements in <tt>array</tt> from the set.
+ *
+ * @param array an <code>array</code> of long primitives.
+ * @return true if the set was modified by the remove all operation.
+ */
+ public boolean removeAll(long[] array) {
+ boolean changed = false;
+ for (int i = array.length; i-- > 0;) {
+ if (remove(array[i])) {
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ /**
+ * Removes any values in the set which are not contained in
+ * <tt>array</tt>.
+ *
+ * @param array an <code>array</code> of long primitives.
+ * @return true if the set was modified by the retain all operation
+ */
+ public boolean retainAll(long[] array) {
+ Arrays.sort(array);
+ long[] set = _set;
+ byte[] states = _states;
+
+ boolean changed = false;
+ for (int i = set.length; i-- > 0;) {
+ if (states[i] == FULL && Arrays.binarySearch(array,set[i]) < 0) {
+ remove(set[i]);
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEach(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ long val = stream.readLong();
+ add(val);
+ }
+ }
+} // TLongHashSet
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongHashingStrategy.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongHashingStrategy.java
new file mode 100755
index 0000000..55ea3c4
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongHashingStrategy.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.Serializable;
+
+/**
+ * Interface to support pluggable hashing strategies in maps and sets.
+ * Implementors can use this interface to make the trove hashing
+ * algorithms use an optimal strategy when computing hashcodes.
+ *
+ * Created: Sun Nov 4 08:56:06 2001
+ *
+ * @author Eric D. Friedman
+ */
+public interface TLongHashingStrategy extends Serializable {
+ /**
+ * Computes a hash code for the specified long. Implementors
+ * can use the long's own value or a custom scheme designed to
+ * minimize collisions for a known set of input.
+ *
+ * @param val long for which the hashcode is to be computed
+ * @return the hashCode
+ */
+ public int computeHashCode(long val);
+} // TLongHashingStrategy
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongIntHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongIntHashMap.java
new file mode 100755
index 0000000..9db4f6b
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongIntHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for long keys and int values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TLongIntHashMap extends TLongHash {
+
+ /** the values of the map */
+ protected transient int[] _values;
+
+ /**
+ * Creates a new <code>TLongIntHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TLongIntHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TLongIntHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TLongIntHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TLongIntHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TLongIntHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TLongIntHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongIntHashMap(TLongHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TLongIntHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongIntHashMap(int initialCapacity, TLongHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TLongIntHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongIntHashMap(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TLongIntHashMap m = (TLongIntHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TLongIntIterator with access to this map's keys and values
+ */
+ public TLongIntIterator iterator() {
+ return new TLongIntIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new int[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>long</code> value
+ * @param value an <code>int</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public int put(long key, int value) {
+ int previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ long[] oldKeys = _set;
+ int[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new long[newCapacity];
+ _values = new int[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ long o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>long</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public int get(long key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ long[] keys = _set;
+ int[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>long</code> value
+ * @return an <code>int</code> value
+ */
+ public int remove(long key) {
+ int prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TLongIntHashMap)) {
+ return false;
+ }
+ TLongIntHashMap that = (TLongIntHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TLongIntProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(long key, int value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TLongIntProcedure {
+ private final TLongIntHashMap _otherMap;
+
+ EqProcedure(TLongIntHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(long key, int value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two ints for equality.
+ */
+ private static boolean eq(int v1, int v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public int[] getValues() {
+ int[] vals = new int[size()];
+ int[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public long[] keys() {
+ long[] keys = new long[size()];
+ long[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>int</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(int val) {
+ byte[] states = _states;
+ int[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>long</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(long key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TLongProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TIntProcedure procedure) {
+ byte[] states = _states;
+ int[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TLongIntProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TLongIntProcedure procedure) {
+ byte[] states = _states;
+ long[] keys = _set;
+ int[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TLongIntProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ long[] keys = _set;
+ int[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TIntFunction</code> value
+ */
+ public void transformValues(TIntFunction function) {
+ byte[] states = _states;
+ int[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(long key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(long key, int amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ long key = stream.readLong();
+ int val = stream.readInt();
+ put(key, val);
+ }
+ }
+} // TLongIntHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongIntIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongIntIterator.java
new file mode 100755
index 0000000..d435919
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongIntIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type long and int.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TLongIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TLongIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TLongIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TLongIntIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TLongIntIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TLongIntHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TLongIntIterator(TLongIntHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public long key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public int value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public int setValue(int val) {
+ int old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TLongIntIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongIntProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongIntProcedure.java
new file mode 100755
index 0000000..faa079d
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongIntProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type long and int.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TLongIntProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>long</code> value
+ * @param b an <code>int</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(long a, int b);
+}// TLongIntProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongIterator.java
new file mode 100755
index 0000000..27f7ae4
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongIterator.java
@@ -0,0 +1,53 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for long collections.
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TLongIterator extends TPrimitiveIterator {
+ /**
+ * the collection on which the iterator operates
+ */
+ private final TLongHash _hash;
+
+ /**
+ * Creates a TLongIterator for the elements in the specified collection.
+ */
+ public TLongIterator(TLongHash hash) {
+ super(hash);
+ _hash = hash;
+ }
+
+ /**
+ * Advances the iterator to the next element in the underlying collection
+ * and returns it.
+ *
+ * @return the next long in the collection
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public long next() {
+ moveToNextIndex();
+ return _hash._set[_index];
+ }
+}// TLongIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongLongHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongLongHashMap.java
new file mode 100755
index 0000000..fad8eb7
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongLongHashMap.java
@@ -0,0 +1,509 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for long keys and long values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TLongLongHashMap extends TLongHash {
+
+ /** the values of the map */
+ protected transient long[] _values;
+
+ /**
+ * Creates a new <code>TLongLongHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TLongLongHashMap() {
+ }
+
+ /**
+ * Creates a new <code>TLongLongHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TLongLongHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TLongLongHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TLongLongHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TLongLongHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongLongHashMap(TLongHashingStrategy strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TLongLongHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongLongHashMap(int initialCapacity, TLongHashingStrategy strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TLongLongHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongLongHashMap(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public Object clone() {
+ TLongLongHashMap m = (TLongLongHashMap)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TLongLongIterator with access to this map's keys and values
+ */
+ public TLongLongIterator iterator() {
+ return new TLongLongIterator(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new long[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>long</code> value
+ * @param value an <code>long</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public long put(long key, long value) {
+ long previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ byte previousState = _states[index];
+ _set[index] = key;
+ _states[index] = FULL;
+ _values[index] = value;
+ if (isNewMapping) {
+ postInsertHook(previousState == FREE);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ long[] oldKeys = _set;
+ long[] oldVals = _values;
+ byte[] oldStates = _states;
+
+ _set = new long[newCapacity];
+ _values = new long[newCapacity];
+ _states = new byte[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldStates[i] == FULL) {
+ long o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ _states[index] = FULL;
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>long</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public long get(long key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ long[] keys = _set;
+ long[] vals = _values;
+ byte[] states = _states;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = 0;
+ vals[i] = 0;
+ states[i] = FREE;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>long</code> value
+ * @return an <code>long</code> value
+ */
+ public long remove(long key) {
+ long prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TLongLongHashMap)) {
+ return false;
+ }
+ TLongLongHashMap that = (TLongLongHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TLongLongProcedure {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(long key, long value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure implements TLongLongProcedure {
+ private final TLongLongHashMap _otherMap;
+
+ EqProcedure(TLongLongHashMap otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(long key, long value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two longs for equality.
+ */
+ private static boolean eq(long v1, long v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public long[] getValues() {
+ long[] vals = new long[size()];
+ long[] v = _values;
+ byte[] states = _states;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public long[] keys() {
+ long[] keys = new long[size()];
+ long[] k = _set;
+ byte[] states = _states;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (states[i] == FULL) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>long</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(long val) {
+ byte[] states = _states;
+ long[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (states[i] == FULL && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>long</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(long key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TLongProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TLongProcedure procedure) {
+ byte[] states = _states;
+ long[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TLongLongProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TLongLongProcedure procedure) {
+ byte[] states = _states;
+ long[] keys = _set;
+ long[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TLongLongProcedure procedure) {
+ boolean modified = false;
+ byte[] states = _states;
+ long[] keys = _set;
+ long[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (states[i] == FULL && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TLongFunction</code> value
+ */
+ public void transformValues(TLongFunction function) {
+ byte[] states = _states;
+ long[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (states[i] == FULL) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(long key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(long key, long amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ long key = stream.readLong();
+ long val = stream.readLong();
+ put(key, val);
+ }
+ }
+} // TLongLongHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongLongIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongLongIterator.java
new file mode 100755
index 0000000..541e13c
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongLongIterator.java
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Iterator for maps of type long and long.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TLongLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TLongLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TLongLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TLongLongIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TLongLongIterator extends TPrimitiveIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TLongLongHashMap _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TLongLongIterator(TLongLongHashMap map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public long key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public long value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public long setValue(long val) {
+ long old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TLongLongIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongLongProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongLongProcedure.java
new file mode 100755
index 0000000..19b8b64
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongLongProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type long and long.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TLongLongProcedure {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>long</code> value
+ * @param b an <code>long</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(long a, long b);
+}// TLongLongProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongObjectHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongObjectHashMap.java
new file mode 100755
index 0000000..855dc60
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongObjectHashMap.java
@@ -0,0 +1,668 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for long keys and Object values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TLongObjectHashMap<V> extends THash implements TLongHashingStrategy {
+
+ /** the values of the map */
+ protected transient V[] _values;
+
+ /** the set of longs */
+ protected transient long[] _set;
+
+ /** strategy used to hash values in this collection */
+ protected final TLongHashingStrategy _hashingStrategy;
+
+ /**
+ * Creates a new <code>TLongObjectHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TLongObjectHashMap() {
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TLongObjectHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TLongObjectHashMap(int initialCapacity) {
+ super(initialCapacity);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TLongObjectHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TLongObjectHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TLongObjectHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongObjectHashMap(TLongHashingStrategy strategy) {
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TLongObjectHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongObjectHashMap(int initialCapacity, TLongHashingStrategy strategy) {
+ super(initialCapacity);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TLongObjectHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TLongObjectHashMap(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * @return a deep clone of this collection
+ */
+ @Override
+ public TLongObjectHashMap<V> clone() {
+ TLongObjectHashMap<V> m = (TLongObjectHashMap<V>)super.clone();
+ m._values = _values.clone();
+ return m;
+ }
+
+ /**
+ * @return a TLongObjectIterator with access to this map's keys and values
+ */
+ public TLongObjectIterator<V> iterator() {
+ return new TLongObjectIterator<V>(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = (V[]) new Object[capacity];
+ _set = new long[capacity];
+
+ return capacity;
+ }
+
+ /**
+ * Searches the set for <tt>val</tt>
+ *
+ * @param val an <code>long</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean contains(long val) {
+ return index(val) >= 0;
+ }
+
+
+ /**
+ * Returns the capacity of the hash table. This is the true
+ * physical capacity, without adjusting for the load factor.
+ *
+ * @return the physical capacity of the hash table.
+ */
+ @Override
+ protected int capacity() {
+ return _values.length;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each element in the set.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return false if the loop over the set terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEach(TLongProcedure procedure) {
+ long[] set = _set;
+ Object[] values = _values;
+ for (int i = set.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(set[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>long</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public V put(long key, V value) {
+ boolean wasFree = false;
+ V previous = null;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = unwrapNull(_values[index]);
+ isNewMapping = false;
+ }
+ else {
+ wasFree = isFree(_values, index);
+ }
+ _set[index] = key;
+ _values[index] = wrapNull(value);
+ if (isNewMapping) {
+ postInsertHook(wasFree);
+ }
+
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ long[] oldKeys = _set;
+ V[] oldVals = _values;
+
+ _set = new long[newCapacity];
+ _values = (V[]) new Object[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(isFull(oldVals, i)) {
+ long o = oldKeys[i];
+ int index = insertionIndex(o);
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>long</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public V get(long key) {
+ int index = index(key);
+ return index < 0 ? null : unwrapNull(_values[index]);
+ }
+
+ private static <V> V unwrapNull(V value) {
+ return value == TObjectHash.NULL ? null : value;
+ }
+ private static <V> V wrapNull(V value) {
+ return value == null ? (V)TObjectHash.NULL : value;
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ long[] keys = _set;
+ Object[] values = _values;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = (long)0;
+ values[i] = null;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>long</code> value
+ * @return an <code>Object</code> value
+ */
+ public V remove(long key) {
+ V prev = null;
+ int index = index(key);
+ if (index >= 0) {
+ prev = unwrapNull(_values[index]);
+ removeAt(index); // clear key,set; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Locates the index of <tt>val</tt>.
+ *
+ * @param val an <code>long</code> value
+ * @return the index of <tt>val</tt> or -1 if it isn't in the set.
+ */
+ protected int index(long val) {
+ long[] set = _set;
+ Object[] values = _values;
+ int length = set.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (!isFree(values, index) &&
+ (isRemoved(values, index) || set[index] != val)) {
+ // see Knuth, p. 529
+ int probe = 1 + (hash % (length - 2));
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ } while (!isFree(values, index) &&
+ (isRemoved(values, index) || set[index] != val));
+ }
+
+ return isFree(values, index) ? -1 : index;
+ }
+
+ /**
+ * Locates the index at which <tt>val</tt> can be inserted. if
+ * there is already a value equal()ing <tt>val</tt> in the set,
+ * returns that value as a negative integer.
+ *
+ * @param val an <code>long</code> value
+ * @return an <code>int</code> value
+ */
+ protected int insertionIndex(long val) {
+ Object[] values = _values;
+ long[] set = _set;
+ int length = set.length;
+ int hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff;
+ int index = hash % length;
+
+ if (isFree(values, index)) {
+ return index; // empty, all done
+ }
+ if (isFull(values, index) && set[index] == val) {
+ return -index -1; // already stored
+ }
+
+ // already FULL or REMOVED, must probe
+ // compute the double hash
+ int probe = 1 + (hash % (length - 2));
+ // starting at the natural offset, probe until we find an
+ // offset that isn't full.
+
+ // keep track of the first removed cell. it's the natural candidate for re-insertion
+ int firstRemoved = isRemoved(values, index) ? index : -1;
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ if (firstRemoved == -1 && isRemoved(values, index)) {
+ firstRemoved = index;
+ }
+ }
+ while (isFull(values, index) && set[index] != val);
+
+ // if the index we found was removed: continue probing until we
+ // locate a free location or an element which equal()s the
+ // one we have.
+ if (isRemoved(values, index)) {
+ while (!isFree(values, index) &&
+ (isRemoved(values, index) || set[index] != val)) {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ }
+ }
+ // if it's full, the key is already stored
+ if (isFull(values, index)) {
+ return -index -1;
+ }
+
+ return firstRemoved == -1 ? index : firstRemoved;
+ }
+
+ static boolean isFull(Object[] values, int index) {
+ Object value = values[index];
+ return value != null && value != TObjectHash.REMOVED;
+ }
+
+ private static boolean isRemoved(Object[] values, int index) {
+ return values[index] == TObjectHash.REMOVED;
+ }
+
+ private static boolean isFree(Object[] values, int index) {
+ return values[index] == null;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean equals(Object other) {
+ if (! (other instanceof TLongObjectHashMap)) {
+ return false;
+ }
+ TLongObjectHashMap that = (TLongObjectHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure<V>(that));
+ }
+
+ public int hashCode() {
+ HashProcedure p = new HashProcedure();
+ forEachEntry(p);
+ return p.getHashCode();
+ }
+
+ private final class HashProcedure implements TLongObjectProcedure<V> {
+ private int h;
+
+ HashProcedure() {
+ }
+
+ public int getHashCode() {
+ return h;
+ }
+
+ @Override
+ public final boolean execute(long key, V value) {
+ h += _hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value);
+ return true;
+ }
+ }
+
+ private static final class EqProcedure<V> implements TLongObjectProcedure<V> {
+ private final TLongObjectHashMap<V> _otherMap;
+
+ EqProcedure(TLongObjectHashMap<V> otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(long key, V value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two objects for equality.
+ */
+ private static boolean eq(Object o1, Object o2) {
+ return o1 == o2 || o1 != null && o1.equals(o2);
+ }
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = (V)TObjectHash.REMOVED;
+ super.removeAt(index); // clear key, set; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a value <code>array</code>
+ */
+ public Object[] getValues() {
+ Object[] vals = new Object[size()];
+ V[] values = _values;
+
+ for (int i = values.length, j = 0; i-- > 0;) {
+ if (isFull(values, i)) {
+ vals[j++] = unwrapNull(values[i]);
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public long[] keys() {
+ long[] keys = new long[size()];
+ long[] k = _set;
+ Object[] values = _values;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (isFull(values, i)) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(V val) {
+ V[] values = _values;
+
+ // special case null values so that we don't have to
+ // perform null checks before every call to equals()
+ if (null == val) {
+ for (int i = values.length; i-- > 0;) {
+ if (TObjectHash.NULL == values[i]) {
+ return true;
+ }
+ }
+ }
+ else {
+ for (int i = values.length; i-- > 0;) {
+ V value = unwrapNull(values[i]);
+ if (isFull(values, i) && (val == value || val.equals(value))) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>long</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(long key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TLongProcedure procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TObjectProcedure<V> procedure) {
+ V[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(unwrapNull(values[i]))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TOLongObjectProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TLongObjectProcedure<V> procedure) {
+ long[] keys = _set;
+ V[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(keys[i],unwrapNull(values[i]))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TLongObjectProcedure<V> procedure) {
+ boolean modified = false;
+ long[] keys = _set;
+ V[] values = _values;
+ stopCompactingOnRemove();
+ try {
+ for (int i = keys.length; i-- > 0;) {
+ if (isFull(values, i) && ! procedure.execute(keys[i],unwrapNull(values[i]))) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ }
+ finally {
+ startCompactingOnRemove(modified);
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TObjectFunction</code> value
+ */
+ public void transformValues(TObjectFunction<V,V> function) {
+ V[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (isFull(values, i)) {
+ values[i] = wrapNull(function.execute(unwrapNull(values[i])));
+ }
+ }
+ }
+
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ long key = stream.readLong();
+ V val = (V) stream.readObject();
+ put(key, val);
+ }
+ }
+
+ /**
+ * Default implementation of TLongHashingStrategy:
+ * delegates hashing to HashFunctions.hash(long).
+ *
+ * @param val the value to hash
+ * @return the hashcode.
+ */
+ @Override
+ public final int computeHashCode(long val) {
+ return HashFunctions.hash(val);
+ }
+
+} // TLongObjectHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongObjectIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongObjectIterator.java
new file mode 100755
index 0000000..d81f06a
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongObjectIterator.java
@@ -0,0 +1,168 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.util.ConcurrentModificationException;
+
+/**
+ * Iterator for maps of type long and Object.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TLongObjectIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TLongObjectIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TLongObjectIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TLongObjectIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+public class TLongObjectIterator <V> extends TIterator {
+ /**
+ * the collection being iterated over
+ */
+ private final TLongObjectHashMap<V> _map;
+
+ /**
+ * Creates an iterator over the specified map
+ */
+ public TLongObjectIterator(TLongObjectHashMap<V> map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Returns the index of the next value in the data structure
+ * or a negative value if the iterator is exhausted.
+ *
+ * @return an <code>int</code> value
+ * @exception ConcurrentModificationException if the underlying collection's
+ * size has been modified since the iterator was created.
+ */
+ @Override
+ protected final int nextIndex() {
+ if (_expectedSize != _map.size()) {
+ throw new ConcurrentModificationException();
+ }
+
+ Object[] values = _map._values;
+ int i = _index;
+ while (i-- > 0 && !TLongObjectHashMap.isFull(values, i));
+ return i;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public long key() {
+ return _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public V value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public V setValue(V val) {
+ V old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TLongObjectIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongObjectProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongObjectProcedure.java
new file mode 100755
index 0000000..165811b
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongObjectProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type long and Object.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TLongObjectProcedure<V> {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>long</code> value
+ * @param b an <code>Object</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(long a, V b);
+}// TLongObjectProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongProcedure.java
new file mode 100755
index 0000000..63adbfe
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TLongProcedure.java
@@ -0,0 +1,40 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures with one long parameter.
+ *
+ * Created: Mon Nov 5 21:45:49 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TLongProcedure {
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param value a value of type <code>long</code>
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(long value);
+}// TLongProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectCanonicalHashingStrategy.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectCanonicalHashingStrategy.java
new file mode 100755
index 0000000..ef01bc5
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectCanonicalHashingStrategy.java
@@ -0,0 +1,16 @@
+package gnu.trove;
+
+/**
+ * @author dyoma
+ */
+class TObjectCanonicalHashingStrategy<T> implements TObjectHashingStrategy<T> {
+ @Override
+ public int computeHashCode(T value) {
+ return value != null ? value.hashCode() : 0;
+ }
+
+ @Override
+ public boolean equals(T value, T value1) {
+ return value != null ? value.equals(value1) : value1 == null;
+ }
+}
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectDoubleHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectDoubleHashMap.java
new file mode 100755
index 0000000..c798be5
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectDoubleHashMap.java
@@ -0,0 +1,483 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for Object keys and double values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TObjectDoubleHashMap<K> extends TObjectHash<K> {
+
+ /** the values of the map */
+ protected transient double[] _values;
+
+ /**
+ * Creates a new <code>TObjectDoubleHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TObjectDoubleHashMap() {
+ super();
+ }
+
+ /**
+ * Creates a new <code>TObjectDoubleHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TObjectDoubleHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TObjectDoubleHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TObjectDoubleHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TObjectDoubleHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TObjectDoubleHashMap(TObjectHashingStrategy<K> strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TObjectDoubleHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TObjectDoubleHashMap(int initialCapacity, TObjectHashingStrategy<K> strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TObjectDoubleHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TObjectDoubleHashMap(int initialCapacity, float loadFactor, TObjectHashingStrategy<K> strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return an iterator over the entries in this map
+ */
+ public TObjectDoubleIterator<K> iterator() {
+ return new TObjectDoubleIterator<K>(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new double[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>double</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public double put(K key, double value) {
+ double previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ K oldKey = (K) _set[index];
+ _set[index] = key;
+ _values[index] = value;
+
+ if (isNewMapping) {
+ postInsertHook(oldKey == null);
+ }
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ K[] oldKeys = (K[]) _set;
+ double[] oldVals = _values;
+
+ _set = new Object[newCapacity];
+ _values = new double[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldKeys[i] != null && oldKeys[i] != REMOVED) {
+ K o = oldKeys[i];
+ int index = insertionIndex(o);
+ if (index < 0) {
+ throwObjectContractViolation(_set[-index -1], o);
+ }
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public double get(K key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ Object[] keys = _set;
+ double[] values = _values;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = null;
+ values[i] = 0;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return an <code>double</code> value
+ */
+ public double remove(K key) {
+ double prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (! (other instanceof TObjectDoubleHashMap)) {
+ return false;
+ }
+ TObjectDoubleHashMap that = (TObjectDoubleHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure<K>(that));
+ }
+
+ private static final class EqProcedure<K> implements TObjectDoubleProcedure<K> {
+ private final TObjectDoubleHashMap<K> _otherMap;
+
+ EqProcedure(TObjectDoubleHashMap<K> otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(K key, double value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two doubles for equality.
+ */
+ private static boolean eq(double v1, double v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public double[] getValues() {
+ double[] vals = new double[size()];
+ double[] v = _values;
+ Object[] keys = _set;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public Object[] keys() {
+ Object[] keys = new Object[size()];
+ K[] k = (K[]) _set;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (k[i] != null && k[i] != REMOVED) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>double</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(double val) {
+ Object[] keys = _set;
+ double[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(K key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TObjectProcedure<K> procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TDoubleProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TDoubleProcedure procedure) {
+ Object[] keys = _set;
+ double[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED
+ && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TOObjectDoubleProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TObjectDoubleProcedure<K> procedure) {
+ K[] keys = (K[]) _set;
+ double[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (keys[i] != null
+ && keys[i] != REMOVED
+ && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TObjectDoubleProcedure<K> procedure) {
+ boolean modified = false;
+ K[] keys = (K[]) _set;
+ double[] values = _values;
+ stopCompactingOnRemove();
+ try {
+ for (int i = keys.length; i-- > 0;) {
+ if (keys[i] != null
+ && keys[i] != REMOVED
+ && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ }
+ finally {
+ startCompactingOnRemove(modified);
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TDoubleFunction</code> value
+ */
+ public void transformValues(TDoubleFunction function) {
+ Object[] keys = _set;
+ double[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(K key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(K key, double amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ K key = (K) stream.readObject();
+ double val = stream.readDouble();
+ put(key, val);
+ }
+ }
+} // TObjectDoubleHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectDoubleIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectDoubleIterator.java
new file mode 100755
index 0000000..72a3135
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectDoubleIterator.java
@@ -0,0 +1,162 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.util.ConcurrentModificationException;
+
+/**
+ * Iterator for maps of type Object and double.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TObjectDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TObjectDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TObjectDoubleIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TObjectDoubleIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TObjectDoubleIterator<K> extends TIterator {
+ private final TObjectDoubleHashMap<K> _map;
+
+ public TObjectDoubleIterator(TObjectDoubleHashMap<K> map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Returns the index of the next value in the data structure
+ * or a negative value if the iterator is exhausted.
+ *
+ * @return an <code>int</code> value
+ */
+ @Override
+ protected final int nextIndex() {
+ if (_expectedSize != _hash.size()) {
+ throw new ConcurrentModificationException();
+ }
+
+ Object[] set = _map._set;
+ int i = _index;
+ while (i-- > 0 && (set[i] == null || set[i] == TObjectHash.REMOVED)) ;
+ return i;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public K key() {
+ //noinspection unchecked
+ return (K) _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public double value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public double setValue(double val) {
+ double old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TObjectDoubleIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectDoubleProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectDoubleProcedure.java
new file mode 100755
index 0000000..ef9e993
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectDoubleProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type Object and double.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TObjectDoubleProcedure<K> {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>Object</code> value
+ * @param b an <code>double</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(K a, double b);
+}// TObjectDoubleProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectFloatHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectFloatHashMap.java
new file mode 100755
index 0000000..3a08539
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectFloatHashMap.java
@@ -0,0 +1,483 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for Object keys and float values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TObjectFloatHashMap<K> extends TObjectHash<K> {
+
+ /** the values of the map */
+ protected transient float[] _values;
+
+ /**
+ * Creates a new <code>TObjectFloatHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TObjectFloatHashMap() {
+ super();
+ }
+
+ /**
+ * Creates a new <code>TObjectFloatHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TObjectFloatHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TObjectFloatHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TObjectFloatHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TObjectFloatHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TObjectFloatHashMap(TObjectHashingStrategy<K> strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TObjectFloatHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TObjectFloatHashMap(int initialCapacity, TObjectHashingStrategy<K> strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TObjectFloatHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TObjectFloatHashMap(int initialCapacity, float loadFactor, TObjectHashingStrategy<K> strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return an iterator over the entries in this map
+ */
+ public TObjectFloatIterator<K> iterator() {
+ return new TObjectFloatIterator<K>(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new float[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>float</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public float put(K key, float value) {
+ float previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ K oldKey = (K) _set[index];
+ _set[index] = key;
+ _values[index] = value;
+
+ if (isNewMapping) {
+ postInsertHook(oldKey == null);
+ }
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ K[] oldKeys = (K[]) _set;
+ float[] oldVals = _values;
+
+ _set = new Object[newCapacity];
+ _values = new float[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldKeys[i] != null && oldKeys[i] != REMOVED) {
+ K o = oldKeys[i];
+ int index = insertionIndex(o);
+ if (index < 0) {
+ throwObjectContractViolation(_set[-index -1], o);
+ }
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public float get(K key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ Object[] keys = _set;
+ float[] values = _values;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = null;
+ values[i] = 0;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return an <code>float</code> value
+ */
+ public float remove(K key) {
+ float prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (! (other instanceof TObjectFloatHashMap)) {
+ return false;
+ }
+ TObjectFloatHashMap that = (TObjectFloatHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure<K>(that));
+ }
+
+ private static final class EqProcedure<K> implements TObjectFloatProcedure<K> {
+ private final TObjectFloatHashMap<K> _otherMap;
+
+ EqProcedure(TObjectFloatHashMap<K> otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(K key, float value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two floats for equality.
+ */
+ private static boolean eq(float v1, float v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public float[] getValues() {
+ float[] vals = new float[size()];
+ float[] v = _values;
+ Object[] keys = _set;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public Object[] keys() {
+ Object[] keys = new Object[size()];
+ K[] k = (K[]) _set;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (k[i] != null && k[i] != REMOVED) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>float</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(float val) {
+ Object[] keys = _set;
+ float[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(K key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TObjectProcedure<K> procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TFloatProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TFloatProcedure procedure) {
+ Object[] keys = _set;
+ float[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED
+ && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TOObjectFloatProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TObjectFloatProcedure<K> procedure) {
+ K[] keys = (K[]) _set;
+ float[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (keys[i] != null
+ && keys[i] != REMOVED
+ && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TObjectFloatProcedure<K> procedure) {
+ boolean modified = false;
+ K[] keys = (K[]) _set;
+ float[] values = _values;
+ stopCompactingOnRemove();
+ try {
+ for (int i = keys.length; i-- > 0;) {
+ if (keys[i] != null
+ && keys[i] != REMOVED
+ && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ }
+ finally {
+ startCompactingOnRemove(modified);
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TFloatFunction</code> value
+ */
+ public void transformValues(TFloatFunction function) {
+ Object[] keys = _set;
+ float[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(K key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(K key, float amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ K key = (K) stream.readObject();
+ float val = stream.readFloat();
+ put(key, val);
+ }
+ }
+} // TObjectFloatHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectFloatIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectFloatIterator.java
new file mode 100755
index 0000000..b1fb34e
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectFloatIterator.java
@@ -0,0 +1,162 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.util.ConcurrentModificationException;
+
+/**
+ * Iterator for maps of type Object and float.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TObjectFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TObjectFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TObjectFloatIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TObjectFloatIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TObjectFloatIterator<K> extends TIterator {
+ private final TObjectFloatHashMap<K> _map;
+
+ public TObjectFloatIterator(TObjectFloatHashMap<K> map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Returns the index of the next value in the data structure
+ * or a negative value if the iterator is exhausted.
+ *
+ * @return an <code>int</code> value
+ */
+ @Override
+ protected final int nextIndex() {
+ if (_expectedSize != _hash.size()) {
+ throw new ConcurrentModificationException();
+ }
+
+ Object[] set = _map._set;
+ int i = _index;
+ while (i-- > 0 && (set[i] == null || set[i] == TObjectHash.REMOVED)) ;
+ return i;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public K key() {
+ //noinspection unchecked
+ return (K) _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public float value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public float setValue(float val) {
+ float old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TObjectFloatIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectFloatProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectFloatProcedure.java
new file mode 100755
index 0000000..5a5f666
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectFloatProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type Object and float.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TObjectFloatProcedure<K> {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>Object</code> value
+ * @param b an <code>float</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(K a, float b);
+}// TObjectFloatProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectFunction.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectFunction.java
new file mode 100755
index 0000000..900c9ae
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectFunction.java
@@ -0,0 +1,38 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+/**
+ * Interface for functions that accept and return one Object reference.
+ *
+ * Created: Mon Nov 5 22:19:36 2001
+ *
+ * @author Eric D. Friedman
+ * @version $Id: TObjectFunction.java,v 1.8 2004/09/24 09:11:15 cdr Exp $
+ */
+
+public interface TObjectFunction<T,R> {
+ /**
+ * Execute this function with <tt>value</tt>
+ *
+ * @param value an <code>Object</code> input
+ * @return an <code>Object</code> result
+ */
+ R execute(T value);
+}// TObjectFunction
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectHash.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectHash.java
new file mode 100755
index 0000000..80f220b
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectHash.java
@@ -0,0 +1,333 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+/**
+ * An open addressed hashing implementation for Object types.
+ *
+ * Created: Sun Nov 4 08:56:06 2001
+ *
+ * @author Eric D. Friedman
+ * @version $Id: TObjectHash.java,v 1.8 2004/09/24 09:11:15 cdr Exp $
+ */
+public abstract class TObjectHash<T> extends THash implements TObjectHashingStrategy<T> {
+ /** the set of Objects */
+ protected transient Object[] _set;
+
+ /** the strategy used to hash objects in this collection. */
+ protected final TObjectHashingStrategy<T> _hashingStrategy;
+
+ public static final Object REMOVED = new Object();
+
+ private static class NULL { NULL() {}}
+ public static final NULL NULL = new NULL();
+
+ /**
+ * Creates a new <code>TObjectHash</code> instance with the
+ * default capacity and load factor.
+ */
+ public TObjectHash() {
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TObjectHash</code> instance with the
+ * default capacity and load factor and a custom hashing strategy.
+ *
+ * @param strategy used to compute hash codes and to compare objects.
+ */
+ public TObjectHash(TObjectHashingStrategy<T> strategy) {
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TObjectHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TObjectHash(int initialCapacity) {
+ super(initialCapacity);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TObjectHash</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime. Uses the specified custom
+ * hashing strategy.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare objects.
+ */
+ public TObjectHash(int initialCapacity, TObjectHashingStrategy<T> strategy) {
+ super(initialCapacity);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * Creates a new <code>TObjectHash</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ */
+ public TObjectHash(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = this;
+ }
+
+ /**
+ * Creates a new <code>TObjectHash</code> instance with a prime
+ * value at or near the specified capacity and load factor. Uses
+ * the specified custom hashing strategy.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare objects.
+ */
+ public TObjectHash(int initialCapacity, float loadFactor, TObjectHashingStrategy<T> strategy) {
+ super(initialCapacity, loadFactor);
+ _hashingStrategy = strategy;
+ }
+
+ /**
+ * @return a shallow clone of this collection
+ */
+ @Override
+ public TObjectHash<T> clone() {
+ TObjectHash<T> h = (TObjectHash<T>)super.clone();
+ h._set = _set.clone();
+ return h;
+ }
+
+ @Override
+ protected int capacity() {
+ return _set.length;
+ }
+
+ @Override
+ protected void removeAt(int index) {
+ _set[index] = REMOVED;
+ super.removeAt(index);
+ }
+
+ /**
+ * initializes the Object set of this hash table.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return an <code>int</code> value
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _set = new Object[capacity];
+ return capacity;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each element in the set.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the set terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEach(TObjectProcedure<T> procedure) {
+ Object[] set = _set;
+ for (int i = set.length; i-- > 0;) {
+ if (set[i] != null
+ && set[i] != REMOVED
+ && ! procedure.execute((T) set[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Searches the set for <tt>obj</tt>
+ *
+ * @param obj an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean contains(Object obj) {
+ return index((T) obj) >= 0;
+ }
+
+ /**
+ * Locates the index of <tt>obj</tt>.
+ *
+ * @param obj an <code>Object</code> value
+ * @return the index of <tt>obj</tt> or -1 if it isn't in the set.
+ */
+ protected int index(T obj) {
+
+ Object[] set = _set;
+ int length = set.length;
+ int hash = _hashingStrategy.computeHashCode(obj) & 0x7fffffff;
+ int index = hash % length;
+ Object cur = set[index];
+
+ if (cur != null
+ && (cur == REMOVED || ! _hashingStrategy.equals((T) cur, obj))) {
+ // see Knuth, p. 529
+ int probe = 1 + hash % (length - 2);
+
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ cur = set[index];
+ } while (cur != null
+ && (cur == REMOVED || ! _hashingStrategy.equals((T) cur, obj)));
+ }
+
+ return cur == null ? -1 : index;
+ }
+
+ /**
+ * Locates the index at which <tt>obj</tt> can be inserted. if
+ * there is already a value equal()ing <tt>obj</tt> in the set,
+ * returns that value's index as <tt>-index - 1</tt>.
+ *
+ * @param obj an <code>Object</code> value
+ * @return the index of a FREE slot at which obj can be inserted
+ * or, if obj is already stored in the hash, the negative value of
+ * that index, minus 1: -index -1.
+ */
+ protected int insertionIndex(T obj) {
+ Object[] set = _set;
+ int length = set.length;
+ int hash = _hashingStrategy.computeHashCode(obj) & 0x7fffffff;
+ int index = hash % length;
+ Object cur = set[index];
+
+ if (cur == null) {
+ return index; // empty, all done
+ }
+ if (cur != REMOVED && _hashingStrategy.equals((T) cur, obj)) {
+ return -index -1; // already stored
+ }
+
+ // already FULL or REMOVED, must probe
+ // compute the double hash
+ int probe = 1 + hash % (length - 2);
+
+ // keep track of the first removed cell. it's the natural candidate for re-insertion
+ int firstRemoved = cur == REMOVED ? index : -1;
+
+ // starting at the natural offset, probe until we find an
+ // offset that isn't full.
+ do {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ cur = set[index];
+ if (firstRemoved == -1 && cur == REMOVED) {
+ firstRemoved = index;
+ }
+ }
+ while (cur != null
+ && cur != REMOVED
+ && !_hashingStrategy.equals((T) cur, obj));
+
+ // if the index we found was removed: continue probing until we
+ // locate a free location or an element which equal()s the
+ // one we have.
+ if (cur == REMOVED) {
+ while (cur != null
+ && (cur == REMOVED || ! _hashingStrategy.equals((T) cur, obj))) {
+ index -= probe;
+ if (index < 0) {
+ index += length;
+ }
+ cur = set[index];
+ }
+ }
+
+ // if it's full, the key is already stored
+ if (cur != null && cur != REMOVED) {
+ return -index -1;
+ }
+
+ return firstRemoved == -1 ? index : firstRemoved;
+ }
+
+ /**
+ * This is the default implementation of TObjectHashingStrategy:
+ * it delegates hashing to the Object's hashCode method.
+ *
+ * @param o for which the hashcode is to be computed
+ * @return the hashCode
+ * @see Object#hashCode()
+ */
+ @Override
+ public final int computeHashCode(T o) {
+ return o != null ? o.hashCode() : 0;
+ }
+
+ /**
+ * This is the default implementation of TObjectHashingStrategy:
+ * it delegates equality comparisons to the first parameter's
+ * equals() method.
+ *
+ * @param o1 an <code>Object</code> value
+ * @param o2 an <code>Object</code> value
+ * @return true if the objects are equal
+ * @see Object#equals(Object)
+ */
+ @Override
+ public final boolean equals(T o1, T o2) {
+ return o1 != null ? o1.equals(o2) : o2 == null;
+ }
+
+ /**
+ * Convenience methods for subclasses to use in throwing exceptions about
+ * badly behaved user objects employed as keys. We have to throw an
+ * IllegalArgumentException with a rather verbose message telling the
+ * user that they need to fix their object implementation to conform
+ * to the general contract for java.lang.Object.
+ *
+ * @param o1 the first of the equal elements with unequal hash codes.
+ * @param o2 the second of the equal elements with unequal hash codes.
+ * @exception IllegalArgumentException the whole point of this method.
+ */
+ protected final void throwObjectContractViolation(Object o1, Object o2)
+ throws IllegalArgumentException {
+ throw new IllegalArgumentException("Equal objects must have equal hashcodes. "
+ + "During rehashing, Trove discovered that "
+ + "the following two objects claim to be "
+ + "equal (as in java.lang.Object.equals() or TObjectHashingStrategy.equals()) "
+ + "but their hashCodes (or those calculated by "
+ + "your TObjectHashingStrategy) are not equal."
+ + "This violates the general contract of "
+ + "java.lang.Object.hashCode(). See bullet point two "
+ + "in that method's documentation. "
+ + "object #1 =" + o1 + (o1 == null ? "" : " ("+o1.getClass()+")")
+ + ", hashCode="+_hashingStrategy.computeHashCode((T)o1)
+ + "; object #2 =" + o2 + (o2 == null ? "" : " ("+o2.getClass()+")")
+ + ", hashCode="+_hashingStrategy.computeHashCode((T)o2)
+ );
+ }
+} // TObjectHash
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectHashIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectHashIterator.java
new file mode 100755
index 0000000..483b636
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectHashIterator.java
@@ -0,0 +1,43 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+
+package gnu.trove;
+
+/**
+ *
+ * Created: Wed Nov 28 21:30:53 2001
+ *
+ * @author Eric D. Friedman
+ * @version $Id: TObjectHashIterator.java,v 1.8 2004/09/24 09:11:15 cdr Exp $
+ */
+
+class TObjectHashIterator<E> extends THashIterator<E> {
+ protected final TObjectHash<E> _objectHash;
+
+ public TObjectHashIterator(TObjectHash<E> hash) {
+ super(hash);
+ _objectHash = hash;
+ }
+
+ @Override
+ protected E objectAtIndex(int index) {
+ return (E)_objectHash._set[index];
+ }
+
+} // TObjectHashIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectHashingStrategy.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectHashingStrategy.java
new file mode 100755
index 0000000..46f2c66
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectHashingStrategy.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+
+package gnu.trove;
+
+import java.io.Serializable;
+
+/**
+ * Interface to support pluggable hashing strategies in maps and sets.
+ * Implementors can use this interface to make the trove hashing
+ * algorithms use object values, values provided by the java runtime,
+ * or a custom strategy when computing hashcodes.
+ *
+ * Created: Sat Aug 17 10:52:32 2002
+ *
+ * @author Eric Friedman
+ * @version $Id: TObjectHashingStrategy.java,v 1.6 2004/09/24 09:11:15 cdr Exp $
+ */
+
+public interface TObjectHashingStrategy<T> extends Serializable, Equality<T> {
+
+ /**
+ * Computes a hash code for the specified object. Implementors
+ * can use the object's own <tt>hashCode</tt> method, the Java
+ * runtime's <tt>identityHashCode</tt>, or a custom scheme.
+ *
+ * @param object for which the hashcode is to be computed
+ * @return the hashCode
+ */
+ int computeHashCode(T object);
+
+ /**
+ * Compares o1 and o2 for equality. Strategy implementors may use
+ * the objects' own equals() methods, compare object references,
+ * or implement some custom scheme.
+ *
+ * @param o1 an <code>Object</code> value
+ * @param o2 an <code>Object</code> value
+ * @return true if the objects are equal according to this strategy.
+ */
+ @Override
+ boolean equals(T o1, T o2);
+
+ TObjectHashingStrategy IDENTITY = new TObjectIdentityHashingStrategy();
+ TObjectHashingStrategy CANONICAL = new TObjectCanonicalHashingStrategy();
+} // TObjectHashingStrategy
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectIdentityHashingStrategy.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectIdentityHashingStrategy.java
new file mode 100755
index 0000000..dd72f9f
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectIdentityHashingStrategy.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+
+package gnu.trove;
+
+/**
+ * This object hashing strategy uses the System.identityHashCode
+ * method to provide identity hash codes. These are identical to the
+ * value produced by Object.hashCode(), even when the type of the
+ * object being hashed overrides that method.
+ *
+ * Created: Sat Aug 17 11:13:15 2002
+ *
+ * @author Eric Friedman
+ * @version $Id: TObjectIdentityHashingStrategy.java,v 1.8 2004/09/24 09:11:15 cdr Exp $
+ */
+
+public final class TObjectIdentityHashingStrategy<T> implements TObjectHashingStrategy<T> {
+ /**
+ * Delegates hash code computation to the System.identityHashCode(Object) method.
+ *
+ * @param object for which the hashcode is to be computed
+ * @return the hashCode
+ */
+ @Override
+ public final int computeHashCode(T object) {
+ return System.identityHashCode(object);
+ }
+
+ /**
+ * Compares object references for equality.
+ *
+ * @param o1 an <code>Object</code> value
+ * @param o2 an <code>Object</code> value
+ * @return true if o1 == o2
+ */
+ @Override
+ public final boolean equals(T o1, T o2) {
+ return o1 == o2;
+ }
+} // TObjectIdentityHashingStrategy
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectIntHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectIntHashMap.java
new file mode 100755
index 0000000..1be4f5a
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectIntHashMap.java
@@ -0,0 +1,483 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for Object keys and int values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TObjectIntHashMap<K> extends TObjectHash<K> {
+
+ /** the values of the map */
+ protected transient int[] _values;
+
+ /**
+ * Creates a new <code>TObjectIntHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TObjectIntHashMap() {
+ super();
+ }
+
+ /**
+ * Creates a new <code>TObjectIntHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TObjectIntHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TObjectIntHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TObjectIntHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TObjectIntHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TObjectIntHashMap(TObjectHashingStrategy<K> strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TObjectIntHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TObjectIntHashMap(int initialCapacity, TObjectHashingStrategy<K> strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TObjectIntHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TObjectIntHashMap(int initialCapacity, float loadFactor, TObjectHashingStrategy<K> strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return an iterator over the entries in this map
+ */
+ public TObjectIntIterator<K> iterator() {
+ return new TObjectIntIterator<K>(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new int[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>int</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public int put(K key, int value) {
+ int previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ K oldKey = (K) _set[index];
+ _set[index] = key;
+ _values[index] = value;
+
+ if (isNewMapping) {
+ postInsertHook(oldKey == null);
+ }
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ K[] oldKeys = (K[]) _set;
+ int[] oldVals = _values;
+
+ _set = new Object[newCapacity];
+ _values = new int[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldKeys[i] != null && oldKeys[i] != REMOVED) {
+ K o = oldKeys[i];
+ int index = insertionIndex(o);
+ if (index < 0) {
+ throwObjectContractViolation(_set[-index -1], o);
+ }
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public int get(K key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ Object[] keys = _set;
+ int[] values = _values;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = null;
+ values[i] = 0;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return an <code>int</code> value
+ */
+ public int remove(K key) {
+ int prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (! (other instanceof TObjectIntHashMap)) {
+ return false;
+ }
+ TObjectIntHashMap that = (TObjectIntHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure<K>(that));
+ }
+
+ private static final class EqProcedure<K> implements TObjectIntProcedure<K> {
+ private final TObjectIntHashMap<K> _otherMap;
+
+ EqProcedure(TObjectIntHashMap<K> otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(K key, int value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two ints for equality.
+ */
+ private static boolean eq(int v1, int v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public int[] getValues() {
+ int[] vals = new int[size()];
+ int[] v = _values;
+ Object[] keys = _set;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public Object[] keys() {
+ Object[] keys = new Object[size()];
+ K[] k = (K[]) _set;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (k[i] != null && k[i] != REMOVED) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>int</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(int val) {
+ Object[] keys = _set;
+ int[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(K key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TObjectProcedure<K> procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TIntProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TIntProcedure procedure) {
+ Object[] keys = _set;
+ int[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED
+ && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TOObjectIntProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TObjectIntProcedure<K> procedure) {
+ K[] keys = (K[]) _set;
+ int[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (keys[i] != null
+ && keys[i] != REMOVED
+ && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TObjectIntProcedure<K> procedure) {
+ boolean modified = false;
+ K[] keys = (K[]) _set;
+ int[] values = _values;
+ stopCompactingOnRemove();
+ try {
+ for (int i = keys.length; i-- > 0;) {
+ if (keys[i] != null
+ && keys[i] != REMOVED
+ && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ }
+ finally {
+ startCompactingOnRemove(modified);
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TIntFunction</code> value
+ */
+ public void transformValues(TIntFunction function) {
+ Object[] keys = _set;
+ int[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(K key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(K key, int amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ K key = (K) stream.readObject();
+ int val = stream.readInt();
+ put(key, val);
+ }
+ }
+} // TObjectIntHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectIntIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectIntIterator.java
new file mode 100755
index 0000000..a090904
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectIntIterator.java
@@ -0,0 +1,162 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.util.ConcurrentModificationException;
+
+/**
+ * Iterator for maps of type Object and int.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TObjectIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TObjectIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TObjectIntIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TObjectIntIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TObjectIntIterator<K> extends TIterator {
+ private final TObjectIntHashMap<K> _map;
+
+ public TObjectIntIterator(TObjectIntHashMap<K> map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Returns the index of the next value in the data structure
+ * or a negative value if the iterator is exhausted.
+ *
+ * @return an <code>int</code> value
+ */
+ @Override
+ protected final int nextIndex() {
+ if (_expectedSize != _hash.size()) {
+ throw new ConcurrentModificationException();
+ }
+
+ Object[] set = _map._set;
+ int i = _index;
+ while (i-- > 0 && (set[i] == null || set[i] == TObjectHash.REMOVED)) ;
+ return i;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public K key() {
+ //noinspection unchecked
+ return (K) _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public int value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public int setValue(int val) {
+ int old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TObjectIntIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectIntProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectIntProcedure.java
new file mode 100755
index 0000000..c89900d
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectIntProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type Object and int.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TObjectIntProcedure<K> {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>Object</code> value
+ * @param b an <code>int</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(K a, int b);
+}// TObjectIntProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectLongHashMap.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectLongHashMap.java
new file mode 100755
index 0000000..2eebd90
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectLongHashMap.java
@@ -0,0 +1,483 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * An open addressed Map implementation for Object keys and long values.
+ *
+ * Created: Sun Nov 4 08:52:45 2001
+ *
+ * @author Eric D. Friedman
+ */
+public class TObjectLongHashMap<K> extends TObjectHash<K> {
+
+ /** the values of the map */
+ protected transient long[] _values;
+
+ /**
+ * Creates a new <code>TObjectLongHashMap</code> instance with the default
+ * capacity and load factor.
+ */
+ public TObjectLongHashMap() {
+ super();
+ }
+
+ /**
+ * Creates a new <code>TObjectLongHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the default load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TObjectLongHashMap(int initialCapacity) {
+ super(initialCapacity);
+ }
+
+ /**
+ * Creates a new <code>TObjectLongHashMap</code> instance with a prime
+ * capacity equal to or greater than <tt>initialCapacity</tt> and
+ * with the specified load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TObjectLongHashMap(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Creates a new <code>TObjectLongHashMap</code> instance with the default
+ * capacity and load factor.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TObjectLongHashMap(TObjectHashingStrategy<K> strategy) {
+ super(strategy);
+ }
+
+ /**
+ * Creates a new <code>TObjectLongHashMap</code> instance whose capacity
+ * is the next highest prime above <tt>initialCapacity + 1</tt>
+ * unless that value is already prime.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TObjectLongHashMap(int initialCapacity, TObjectHashingStrategy<K> strategy) {
+ super(initialCapacity, strategy);
+ }
+
+ /**
+ * Creates a new <code>TObjectLongHashMap</code> instance with a prime
+ * value at or near the specified capacity and load factor.
+ *
+ * @param initialCapacity used to find a prime capacity for the table.
+ * @param loadFactor used to calculate the threshold over which
+ * rehashing takes place.
+ * @param strategy used to compute hash codes and to compare keys.
+ */
+ public TObjectLongHashMap(int initialCapacity, float loadFactor, TObjectHashingStrategy<K> strategy) {
+ super(initialCapacity, loadFactor, strategy);
+ }
+
+ /**
+ * @return an iterator over the entries in this map
+ */
+ public TObjectLongIterator<K> iterator() {
+ return new TObjectLongIterator<K>(this);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _values = new long[capacity];
+ return capacity;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>long</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or null if none was found.
+ */
+ public long put(K key, long value) {
+ long previous = 0;
+ int index = insertionIndex(key);
+ boolean isNewMapping = true;
+ if (index < 0) {
+ index = -index -1;
+ previous = _values[index];
+ isNewMapping = false;
+ }
+ K oldKey = (K) _set[index];
+ _set[index] = key;
+ _values[index] = value;
+
+ if (isNewMapping) {
+ postInsertHook(oldKey == null);
+ }
+ return previous;
+ }
+
+ /**
+ * rehashes the map to the new capacity.
+ *
+ * @param newCapacity an <code>int</code> value
+ */
+ @Override
+ protected void rehash(int newCapacity) {
+ int oldCapacity = _set.length;
+ K[] oldKeys = (K[]) _set;
+ long[] oldVals = _values;
+
+ _set = new Object[newCapacity];
+ _values = new long[newCapacity];
+
+ for (int i = oldCapacity; i-- > 0;) {
+ if(oldKeys[i] != null && oldKeys[i] != REMOVED) {
+ K o = oldKeys[i];
+ int index = insertionIndex(o);
+ if (index < 0) {
+ throwObjectContractViolation(_set[-index -1], o);
+ }
+ _set[index] = o;
+ _values[index] = oldVals[i];
+ }
+ }
+ }
+
+ /**
+ * retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public long get(K key) {
+ int index = index(key);
+ return index < 0 ? 0 : _values[index];
+ }
+
+ /**
+ * Empties the map.
+ *
+ */
+ @Override
+ public void clear() {
+ super.clear();
+ Object[] keys = _set;
+ long[] values = _values;
+
+ for (int i = keys.length; i-- > 0;) {
+ keys[i] = null;
+ values[i] = 0;
+ }
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return an <code>long</code> value
+ */
+ public long remove(K key) {
+ long prev = 0;
+ int index = index(key);
+ if (index >= 0) {
+ prev = _values[index];
+ removeAt(index); // clear key,state; adjust size
+ }
+ return prev;
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (! (other instanceof TObjectLongHashMap)) {
+ return false;
+ }
+ TObjectLongHashMap that = (TObjectLongHashMap)other;
+ if (that.size() != this.size()) {
+ return false;
+ }
+ return forEachEntry(new EqProcedure<K>(that));
+ }
+
+ private static final class EqProcedure<K> implements TObjectLongProcedure<K> {
+ private final TObjectLongHashMap<K> _otherMap;
+
+ EqProcedure(TObjectLongHashMap<K> otherMap) {
+ _otherMap = otherMap;
+ }
+
+ @Override
+ public final boolean execute(K key, long value) {
+ int index = _otherMap.index(key);
+ return index >= 0 && eq(value, _otherMap.get(key));
+ }
+
+ /**
+ * Compare two longs for equality.
+ */
+ private static boolean eq(long v1, long v2) {
+ return v1 == v2;
+ }
+
+ }
+
+ /**
+ * removes the mapping at <tt>index</tt> from the map.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _values[index] = 0;
+ super.removeAt(index); // clear key, state; adjust size
+ }
+
+ /**
+ * Returns the values of the map.
+ *
+ * @return a <code>Collection</code> value
+ */
+ public long[] getValues() {
+ long[] vals = new long[size()];
+ long[] v = _values;
+ Object[] keys = _set;
+
+ for (int i = v.length, j = 0; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED) {
+ vals[j++] = v[i];
+ }
+ }
+ return vals;
+ }
+
+ /**
+ * returns the keys of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ public Object[] keys() {
+ Object[] keys = new Object[size()];
+ K[] k = (K[]) _set;
+
+ for (int i = k.length, j = 0; i-- > 0;) {
+ if (k[i] != null && k[i] != REMOVED) {
+ keys[j++] = k[i];
+ }
+ }
+ return keys;
+ }
+
+ /**
+ * checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>long</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsValue(long val) {
+ Object[] keys = _set;
+ long[] vals = _values;
+
+ for (int i = vals.length; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED && val == vals[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ public boolean containsKey(K key) {
+ return contains(key);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key in the map.
+ *
+ * @param procedure a <code>TObjectProcedure</code> value
+ * @return false if the loop over the keys terminated because
+ * the procedure returned false for some key.
+ */
+ public boolean forEachKey(TObjectProcedure<K> procedure) {
+ return forEach(procedure);
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each value in the map.
+ *
+ * @param procedure a <code>TLongProcedure</code> value
+ * @return false if the loop over the values terminated because
+ * the procedure returned false for some value.
+ */
+ public boolean forEachValue(TLongProcedure procedure) {
+ Object[] keys = _set;
+ long[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED
+ && ! procedure.execute(values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Executes <tt>procedure</tt> for each key/value entry in the
+ * map.
+ *
+ * @param procedure a <code>TOObjectLongProcedure</code> value
+ * @return false if the loop over the entries terminated because
+ * the procedure returned false for some entry.
+ */
+ public boolean forEachEntry(TObjectLongProcedure<K> procedure) {
+ K[] keys = (K[]) _set;
+ long[] values = _values;
+ for (int i = keys.length; i-- > 0;) {
+ if (keys[i] != null
+ && keys[i] != REMOVED
+ && ! procedure.execute(keys[i],values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retains only those entries in the map for which the procedure
+ * returns a true value.
+ *
+ * @param procedure determines which entries to keep
+ * @return true if the map was modified.
+ */
+ public boolean retainEntries(TObjectLongProcedure<K> procedure) {
+ boolean modified = false;
+ K[] keys = (K[]) _set;
+ long[] values = _values;
+ stopCompactingOnRemove();
+ try {
+ for (int i = keys.length; i-- > 0;) {
+ if (keys[i] != null
+ && keys[i] != REMOVED
+ && ! procedure.execute(keys[i],values[i])) {
+ removeAt(i);
+ modified = true;
+ }
+ }
+ }
+ finally {
+ startCompactingOnRemove(modified);
+ }
+ return modified;
+ }
+
+ /**
+ * Transform the values in this map using <tt>function</tt>.
+ *
+ * @param function a <code>TLongFunction</code> value
+ */
+ public void transformValues(TLongFunction function) {
+ Object[] keys = _set;
+ long[] values = _values;
+ for (int i = values.length; i-- > 0;) {
+ if (keys[i] != null && keys[i] != REMOVED) {
+ values[i] = function.execute(values[i]);
+ }
+ }
+ }
+
+ /**
+ * Increments the primitive value mapped to key by 1
+ *
+ * @param key the key of the value to increment
+ * @return true if a mapping was found and modified.
+ */
+ public boolean increment(K key) {
+ return adjustValue(key, 1);
+ }
+
+ /**
+ * Adjusts the primitive value mapped to key.
+ *
+ * @param key the key of the value to increment
+ * @param amount the amount to adjust the value by.
+ * @return true if a mapping was found and modified.
+ */
+ public boolean adjustValue(K key, long amount) {
+ int index = index(key);
+ if (index < 0) {
+ return false;
+ } else {
+ _values[index] += amount;
+ return true;
+ }
+ }
+
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException {
+ stream.defaultWriteObject();
+
+ // number of entries
+ stream.writeInt(_size);
+
+ SerializationProcedure writeProcedure = new SerializationProcedure(stream);
+ if (! forEachEntry(writeProcedure)) {
+ throw writeProcedure.exception;
+ }
+ }
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ int size = stream.readInt();
+ setUp(size);
+ while (size-- > 0) {
+ K key = (K) stream.readObject();
+ long val = stream.readLong();
+ put(key, val);
+ }
+ }
+} // TObjectLongHashMap
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectLongIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectLongIterator.java
new file mode 100755
index 0000000..8bdcbb0
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectLongIterator.java
@@ -0,0 +1,162 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+import java.util.ConcurrentModificationException;
+
+/**
+ * Iterator for maps of type Object and long.
+ * <p/>
+ * <p>The iterator semantics for Trove's primitive maps is slightly different
+ * from those defined in <tt>java.util.Iterator</tt>, but still well within
+ * the scope of the pattern, as defined by Gamma, et al.</p>
+ * <p/>
+ * <p>This iterator does <b>not</b> implicitly advance to the next entry when
+ * the value at the current position is retrieved. Rather, you must explicitly
+ * ask the iterator to <tt>advance()</tt> and then retrieve either the <tt>key()</tt>,
+ * the <tt>value()</tt> or both. This is done so that you have the option, but not
+ * the obligation, to retrieve keys and/or values as your application requires, and
+ * without introducing wrapper objects that would carry both. As the iteration is
+ * stateful, access to the key/value parts of the current map entry happens in
+ * constant time.</p>
+ * <p/>
+ * <p>In practice, the iterator is akin to a "search finger" that you move from
+ * position to position. Read or write operations affect the current entry only and
+ * do not assume responsibility for moving the finger.</p>
+ * <p/>
+ * <p>Here are some sample scenarios for this class of iterator:</p>
+ * <p/>
+ * <pre>
+ * // accessing keys/values through an iterator:
+ * for (TObjectLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * doSomethingWithValue(it.value());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // modifying values in-place through iteration:
+ * for (TObjectLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.setValue(newValueForKey(it.key()));
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // deleting entries during iteration:
+ * for (TObjectLongIterator it = map.iterator();
+ * it.hasNext();) {
+ * it.forward();
+ * if (satisfiesCondition(it.key()) {
+ * it.remove();
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <pre>
+ * // faster iteration by avoiding hasNext():
+ * TObjectLongIterator iterator = map.iterator();
+ * for (int i = map.size(); i-- > 0;) {
+ * iterator.advance();
+ * doSomethingWithKeyAndValue(iterator.key(), iterator.value());
+ * }
+ * </pre>
+ *
+ * @author Eric D. Friedman
+ */
+
+public class TObjectLongIterator<K> extends TIterator {
+ private final TObjectLongHashMap<K> _map;
+
+ public TObjectLongIterator(TObjectLongHashMap<K> map) {
+ super(map);
+ _map = map;
+ }
+
+ /**
+ * Returns the index of the next value in the data structure
+ * or a negative value if the iterator is exhausted.
+ *
+ * @return an <code>int</code> value
+ */
+ @Override
+ protected final int nextIndex() {
+ if (_expectedSize != _hash.size()) {
+ throw new ConcurrentModificationException();
+ }
+
+ Object[] set = _map._set;
+ int i = _index;
+ while (i-- > 0 && (set[i] == null || set[i] == TObjectHash.REMOVED)) ;
+ return i;
+ }
+
+ /**
+ * Moves the iterator forward to the next entry in the underlying map.
+ *
+ * @throws java.util.NoSuchElementException
+ * if the iterator is already exhausted
+ */
+ public void advance() {
+ moveToNextIndex();
+ }
+
+ /**
+ * Provides access to the key of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the key of the entry at the iterator's current position.
+ */
+ public K key() {
+ //noinspection unchecked
+ return (K) _map._set[_index];
+ }
+
+ /**
+ * Provides access to the value of the mapping at the iterator's position.
+ * Note that you must <tt>advance()</tt> the iterator at least once
+ * before invoking this method.
+ *
+ * @return the value of the entry at the iterator's current position.
+ */
+ public long value() {
+ return _map._values[_index];
+ }
+
+ /**
+ * Replace the value of the mapping at the iterator's position with the
+ * specified value. Note that you must <tt>advance()</tt> the iterator at
+ * least once before invoking this method.
+ *
+ * @param val the value to set in the current entry
+ * @return the old value of the entry.
+ */
+ public long setValue(long val) {
+ long old = value();
+ _map._values[_index] = val;
+ return old;
+ }
+}// TObjectLongIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectLongProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectLongProcedure.java
new file mode 100755
index 0000000..1d8fbb8
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectLongProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two parameters of type Object and long.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ */
+
+public interface TObjectLongProcedure<K> {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>Object</code> value
+ * @param b an <code>long</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(K a, long b);
+}// TObjectLongProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectObjectProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectObjectProcedure.java
new file mode 100755
index 0000000..535786f
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectObjectProcedure.java
@@ -0,0 +1,43 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+/**
+ * Interface for procedures that take two Object parameters.
+ *
+ * Created: Mon Nov 5 22:03:30 2001
+ *
+ * @author Eric D. Friedman
+ * @version $Id: TObjectObjectProcedure.java,v 1.8 2004/09/24 09:11:15 cdr Exp $
+ */
+
+public interface TObjectObjectProcedure<K,V> {
+
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param a an <code>Object</code> value
+ * @param b an <code>Object</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(K a, V b);
+}// TObjectObjectProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectProcedure.java
new file mode 100755
index 0000000..4827cd4
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TObjectProcedure.java
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+
+package gnu.trove;
+
+/**
+ * Interface for procedures with one Object paramater.
+ *
+ * Created: Mon Nov 5 21:45:49 2001
+ *
+ * @author Eric D. Friedman
+ * @version $Id: TObjectProcedure.java,v 1.8 2004/09/24 09:11:15 cdr Exp $
+ */
+
+public interface TObjectProcedure<T> {
+ /**
+ * Executes this procedure. A false return value indicates that
+ * the application executing this procedure should not invoke this
+ * procedure again.
+ *
+ * @param object an <code>Object</code> value
+ * @return true if additional invocations of the procedure are
+ * allowed.
+ */
+ boolean execute(T object);
+}// TObjectProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TPrimitiveHash.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TPrimitiveHash.java
new file mode 100755
index 0000000..c22580e
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TPrimitiveHash.java
@@ -0,0 +1,126 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+/**
+ * The base class for hashtables of primitive values. Since there is
+ * no notion of object equality for primitives, it isn't possible to
+ * use a `REMOVED' object to track deletions in an open-addressed table.
+ * So, we have to resort to using a parallel `bookkeeping' array of bytes,
+ * in which flags can be set to indicate that a particular slot in the
+ * hash table is FREE, FULL, or REMOVED.
+ *
+ * Created: Fri Jan 11 18:55:16 2002
+ *
+ * @author Eric D. Friedman
+ * @version $Id: TPrimitiveHash.java,v 1.8 2004/09/24 09:11:15 cdr Exp $
+ */
+
+public abstract class TPrimitiveHash extends THash {
+ /** flags indicating whether each position in the hash is
+ * FREE, FULL, or REMOVED */
+ protected transient byte[] _states;
+
+ /* constants used for state flags */
+
+ /** flag indicating that a slot in the hashtable is available */
+ protected static final byte FREE = 0;
+
+ /** flag indicating that a slot in the hashtable is occupied */
+ protected static final byte FULL = 1;
+
+ /** flag indicating that the value of a slot in the hashtable
+ * was deleted */
+ protected static final byte REMOVED = 2;
+
+ /**
+ * Creates a new <code>THash</code> instance with the default
+ * capacity and load factor.
+ */
+ public TPrimitiveHash() {
+ super();
+ }
+
+ /**
+ * Creates a new <code>TPrimitiveHash</code> instance with a prime
+ * capacity at or near the specified capacity and with the default
+ * load factor.
+ *
+ * @param initialCapacity an <code>int</code> value
+ */
+ public TPrimitiveHash(int initialCapacity) {
+ this(initialCapacity, DEFAULT_LOAD_FACTOR);
+ }
+
+ /**
+ * Creates a new <code>TPrimitiveHash</code> instance with a prime
+ * capacity at or near the minimum needed to hold
+ * <tt>initialCapacity<tt> elements with load factor
+ * <tt>loadFactor</tt> without triggering a rehash.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @param loadFactor a <code>float</code> value
+ */
+ public TPrimitiveHash(int initialCapacity, float loadFactor) {
+ super(initialCapacity, loadFactor);
+ }
+
+ @Override
+ public Object clone() {
+ TPrimitiveHash h = (TPrimitiveHash)super.clone();
+ h._states = _states.clone();
+ return h;
+ }
+
+ /**
+ * Returns the capacity of the hash table. This is the true
+ * physical capacity, without adjusting for the load factor.
+ *
+ * @return the physical capacity of the hash table.
+ */
+ @Override
+ protected int capacity() {
+ return _states.length;
+ }
+
+ /**
+ * Delete the record at <tt>index</tt>.
+ *
+ * @param index an <code>int</code> value
+ */
+ @Override
+ protected void removeAt(int index) {
+ _states[index] = REMOVED;
+ super.removeAt(index);
+ }
+
+ /**
+ * initializes the hashtable to a prime capacity which is at least
+ * <tt>initialCapacity + 1</tt>.
+ *
+ * @param initialCapacity an <code>int</code> value
+ * @return the actual capacity chosen
+ */
+ @Override
+ protected int setUp(int initialCapacity) {
+ int capacity = super.setUp(initialCapacity);
+ _states = new byte[capacity];
+ return capacity;
+ }
+} // TPrimitiveHash
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/TPrimitiveIterator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TPrimitiveIterator.java
new file mode 100755
index 0000000..2fab846
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/TPrimitiveIterator.java
@@ -0,0 +1,76 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+import java.util.ConcurrentModificationException;
+
+/**
+ * Implements all iterator functions for the hashed object set.
+ * Subclasses may override objectAtIndex to vary the object
+ * returned by calls to next() (e.g. for values, and Map.Entry
+ * objects).
+ *
+ * <p> Note that iteration is fastest if you forego the calls to
+ * <tt>hasNext</tt> in favor of checking the size of the structure
+ * yourself and then call next() that many times:
+ *
+ * <pre>
+ * Iterator i = collection.iterator();
+ * for (int size = collection.size(); size-- > 0;) {
+ * Object o = i.next();
+ * }
+ * </pre>
+ *
+ * <p>You may, of course, use the hasNext(), next() idiom too if
+ * you aren't in a performance critical spot.</p>
+ *
+ */
+abstract class TPrimitiveIterator extends TIterator {
+ /** the collection on which this iterator operates. */
+ protected final TPrimitiveHash _hash;
+
+ /**
+ * Creates a TPrimitiveIterator for the specified collection.
+ */
+ public TPrimitiveIterator(TPrimitiveHash hash) {
+ super(hash);
+ _hash = hash;
+ }
+
+ /**
+ * Returns the index of the next value in the data structure
+ * or a negative value if the iterator is exhausted.
+ *
+ * @return an <code>int</code> value
+ * @exception ConcurrentModificationException if the underlying collection's
+ * size has been modified since the iterator was created.
+ */
+ @Override
+ protected final int nextIndex() {
+ if (_expectedSize != _hash.size()) {
+ throw new ConcurrentModificationException();
+ }
+
+ byte[] states = _hash._states;
+ int i = _index;
+ while (i-- > 0 && (states[i] != TPrimitiveHash.FULL)) ;
+ return i;
+ }
+
+} // TPrimitiveIterator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/ToObjectArrayProcedure.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/ToObjectArrayProcedure.java
new file mode 100755
index 0000000..3e1a3ee
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/ToObjectArrayProcedure.java
@@ -0,0 +1,43 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+
+package gnu.trove;
+
+/**
+ * A procedure which stores each value it receives into a target array.
+ *
+ * Created: Sat Jan 12 10:13:42 2002
+ *
+ * @author Eric D. Friedman
+ * @version $Id: ToObjectArrayProcedure.java,v 1.8 2004/09/24 09:11:15 cdr Exp $
+ */
+
+final class ToObjectArrayProcedure<T> implements TObjectProcedure<T> {
+ private final T[] target;
+ private int pos;
+
+ public ToObjectArrayProcedure(final T[] target) {
+ this.target = target;
+ }
+
+ @Override
+ public final boolean execute(T value) {
+ target[pos++] = value;
+ return true;
+ }
+} // ToObjectArrayProcedure
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleDoubleHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleDoubleHashMapDecorator.java
new file mode 100755
index 0000000..40a3709
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleDoubleHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TDoubleDoubleHashMap;
+import gnu.trove.TDoubleDoubleIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TDoubleDoubleHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TDoubleDoubleHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TDoubleDoubleHashMapDecorator extends AbstractMap<Double, Double> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TDoubleDoubleHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TDoubleDoubleHashMapDecorator(TDoubleDoubleHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Double(0) if none was found.
+ */
+ @Override
+ public Double put(Double key, Double value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Double && val instanceof Double) {
+ double k = unwrapKey(key);
+ double v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Double get(Object object) {
+ return get((Double)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Double get(Double key) {
+ double k = unwrapKey(key);
+ double v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Double(0) if it was not found in the map
+ */
+ public Double remove(Double key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Double remove(Object object) {
+ return remove((Double)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Double,Double>> entrySet() {
+ return new AbstractSet<Map.Entry<Double,Double>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TDoubleDoubleHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TDoubleDoubleHashMapDecorator.this.containsKey(k)
+ && TDoubleDoubleHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Double,Double>> iterator() {
+ return new Iterator<Map.Entry<Double,Double>>() {
+ private final TDoubleDoubleIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Double,Double> next() {
+ it.advance();
+ final Double key = wrapKey(it.key());
+ final Double v = wrapValue(it.value());
+ return new Map.Entry<Double,Double>() {
+ private Double val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Double getKey() {
+ return key;
+ }
+
+ @Override
+ public Double getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Double setValue(Double value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Double,Double> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Double, Double>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TDoubleDoubleHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Double, ? extends Double> map) {
+ Iterator<? extends Entry<? extends Double,? extends Double>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Double,? extends Double> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Double wrapKey(double k) {
+ return new Double(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected double unwrapKey(Object key) {
+ return ((Double)key).doubleValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Double wrapValue(double k) {
+ return new Double(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected double unwrapValue(Object value) {
+ return ((Double)value).doubleValue();
+ }
+
+} // TDoubleDoubleHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleFloatHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleFloatHashMapDecorator.java
new file mode 100755
index 0000000..00400a6
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleFloatHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TDoubleFloatHashMap;
+import gnu.trove.TDoubleFloatIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TDoubleFloatHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TDoubleFloatHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TDoubleFloatHashMapDecorator extends AbstractMap<Double, Float> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TDoubleFloatHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TDoubleFloatHashMapDecorator(TDoubleFloatHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Float(0) if none was found.
+ */
+ @Override
+ public Float put(Double key, Float value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Double && val instanceof Float) {
+ double k = unwrapKey(key);
+ float v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Float get(Object object) {
+ return get((Double)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Float get(Double key) {
+ double k = unwrapKey(key);
+ float v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Float(0) if it was not found in the map
+ */
+ public Float remove(Double key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Float remove(Object object) {
+ return remove((Float)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Double,Float>> entrySet() {
+ return new AbstractSet<Map.Entry<Double,Float>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TDoubleFloatHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TDoubleFloatHashMapDecorator.this.containsKey(k)
+ && TDoubleFloatHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Double,Float>> iterator() {
+ return new Iterator<Map.Entry<Double,Float>>() {
+ private final TDoubleFloatIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Double,Float> next() {
+ it.advance();
+ final Double key = wrapKey(it.key());
+ final Float v = wrapValue(it.value());
+ return new Map.Entry<Double,Float>() {
+ private Float val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Double getKey() {
+ return key;
+ }
+
+ @Override
+ public Float getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Float setValue(Float value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Double,Float> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Double, Float>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TDoubleFloatHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Double, ? extends Float> map) {
+ Iterator<? extends Entry<? extends Double,? extends Float>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Double,? extends Float> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Double wrapKey(double k) {
+ return new Double(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected double unwrapKey(Object key) {
+ return ((Double)key).doubleValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Float wrapValue(float k) {
+ return new Float(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected float unwrapValue(Object value) {
+ return ((Float)value).floatValue();
+ }
+
+} // TDoubleFloatHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleHashSetDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleHashSetDecorator.java
new file mode 100755
index 0000000..688ba45
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleHashSetDecorator.java
@@ -0,0 +1,189 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TDoubleHashSet;
+import gnu.trove.TDoubleIterator;
+
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TDoubleHashSet conform to the <tt>java.util.Set</tt> API.
+ * This class simply decorates an underlying TDoubleHashSet and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Tue Sep 24 22:08:17 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TDoubleHashSetDecorator extends AbstractSet<Double> implements Set<Double> {
+ /**
+ * the wrapped primitive set
+ */
+ protected final TDoubleHashSet _set;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive set.
+ */
+ public TDoubleHashSetDecorator(TDoubleHashSet set) {
+ super();
+ this._set = set;
+ }
+
+ /**
+ * Inserts a value into the set.
+ *
+ * @param value true if the set was modified by the insertion
+ */
+ @Override
+ public boolean add(Double value) {
+ return _set.add(unwrap(value));
+ }
+
+ /**
+ * Compares this set with another set for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the sets are identical
+ */
+ public boolean equals(Object other) {
+ if (_set.equals(other)) {
+ return true; // comparing two trove sets
+ } else if (other instanceof Set) {
+ Set that = (Set) other;
+ if (that.size() != _set.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Object val = it.next();
+ if (val instanceof Double) {
+ double v = unwrap(val);
+ if (_set.contains(v)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other set
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Empties the set.
+ */
+ @Override
+ public void clear() {
+ this._set.clear();
+ }
+
+ /**
+ * Deletes a value from the set.
+ *
+ * @param value an <code>Object</code> value
+ * @return true if the set was modified
+ */
+ @Override
+ public boolean remove(Object value) {
+ return _set.remove(unwrap(value));
+ }
+
+ /**
+ * Creates an iterator over the values of the set.
+ *
+ * @return an iterator with support for removals in the underlying set
+ */
+ @Override
+ public Iterator<Double> iterator() {
+ return new Iterator<Double>() {
+ private final TDoubleIterator it = _set.iterator();
+
+ @Override
+ public Double next() {
+ return wrap(it.next());
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ /**
+ * Returns the number of entries in the set.
+ *
+ * @return the set's size.
+ */
+ @Override
+ public int size() {
+ return this._set.size();
+ }
+
+ /**
+ * Indicates whether set has any entries.
+ *
+ * @return true if the set is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying set
+ * @return an Object representation of the value
+ */
+ protected Double wrap(double k) {
+ return new Double(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected double unwrap(Object value) {
+ return ((Double) value).doubleValue();
+ }
+} // TDoubleHashSetDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleIntHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleIntHashMapDecorator.java
new file mode 100755
index 0000000..fe5e820
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleIntHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TDoubleIntHashMap;
+import gnu.trove.TDoubleIntIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TDoubleIntHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TDoubleIntHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TDoubleIntHashMapDecorator extends AbstractMap<Double, Integer> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TDoubleIntHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TDoubleIntHashMapDecorator(TDoubleIntHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Integer(0) if none was found.
+ */
+ @Override
+ public Integer put(Double key, Integer value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Double && val instanceof Integer) {
+ double k = unwrapKey(key);
+ int v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Integer get(Object object) {
+ return get((Double)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Integer get(Double key) {
+ double k = unwrapKey(key);
+ int v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Integer(0) if it was not found in the map
+ */
+ public Integer remove(Double key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Integer remove(Object object) {
+ return remove((Integer)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Double,Integer>> entrySet() {
+ return new AbstractSet<Map.Entry<Double,Integer>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TDoubleIntHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TDoubleIntHashMapDecorator.this.containsKey(k)
+ && TDoubleIntHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Double,Integer>> iterator() {
+ return new Iterator<Map.Entry<Double,Integer>>() {
+ private final TDoubleIntIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Double,Integer> next() {
+ it.advance();
+ final Double key = wrapKey(it.key());
+ final Integer v = wrapValue(it.value());
+ return new Map.Entry<Double,Integer>() {
+ private Integer val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Double getKey() {
+ return key;
+ }
+
+ @Override
+ public Integer getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Integer setValue(Integer value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Double,Integer> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Double, Integer>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TDoubleIntHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Double, ? extends Integer> map) {
+ Iterator<? extends Entry<? extends Double,? extends Integer>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Double,? extends Integer> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Double wrapKey(double k) {
+ return new Double(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected double unwrapKey(Object key) {
+ return ((Double)key).doubleValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Integer wrapValue(int k) {
+ return new Integer(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected int unwrapValue(Object value) {
+ return ((Integer)value).intValue();
+ }
+
+} // TDoubleIntHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleLongHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleLongHashMapDecorator.java
new file mode 100755
index 0000000..c729c87
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleLongHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TDoubleLongHashMap;
+import gnu.trove.TDoubleLongIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TDoubleLongHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TDoubleLongHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TDoubleLongHashMapDecorator extends AbstractMap<Double, Long> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TDoubleLongHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TDoubleLongHashMapDecorator(TDoubleLongHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Long(0) if none was found.
+ */
+ @Override
+ public Long put(Double key, Long value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Double && val instanceof Long) {
+ double k = unwrapKey(key);
+ long v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Long get(Object object) {
+ return get((Double)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Long get(Double key) {
+ double k = unwrapKey(key);
+ long v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Long(0) if it was not found in the map
+ */
+ public Long remove(Double key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Long remove(Object object) {
+ return remove((Long)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Double,Long>> entrySet() {
+ return new AbstractSet<Map.Entry<Double,Long>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TDoubleLongHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TDoubleLongHashMapDecorator.this.containsKey(k)
+ && TDoubleLongHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Double,Long>> iterator() {
+ return new Iterator<Map.Entry<Double,Long>>() {
+ private final TDoubleLongIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Double,Long> next() {
+ it.advance();
+ final Double key = wrapKey(it.key());
+ final Long v = wrapValue(it.value());
+ return new Map.Entry<Double,Long>() {
+ private Long val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Double getKey() {
+ return key;
+ }
+
+ @Override
+ public Long getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Long setValue(Long value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Double,Long> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Double, Long>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TDoubleLongHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Double, ? extends Long> map) {
+ Iterator<? extends Entry<? extends Double,? extends Long>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Double,? extends Long> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Double wrapKey(double k) {
+ return new Double(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected double unwrapKey(Object key) {
+ return ((Double)key).doubleValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Long wrapValue(long k) {
+ return new Long(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected long unwrapValue(Object value) {
+ return ((Long)value).longValue();
+ }
+
+} // TDoubleLongHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleObjectHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleObjectHashMapDecorator.java
new file mode 100755
index 0000000..97aee15
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TDoubleObjectHashMapDecorator.java
@@ -0,0 +1,360 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TDoubleObjectHashMap;
+import gnu.trove.TDoubleObjectIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TDoubleObjectHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TDoubleObjectHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TDoubleObjectHashMapDecorator <V> extends AbstractMap<Double, V> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TDoubleObjectHashMap<V> _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TDoubleObjectHashMapDecorator(TDoubleObjectHashMap<V> map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Integer(0) if none was found.
+ */
+ @Override
+ public V put(Double key, V value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Double) {
+ double k = unwrapKey(key);
+ Object v = unwrapValue((V) val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ @Override
+ public V get(Object key) {
+ return _map.get(unwrapKey(key));
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Integer(0) if it was not found in the map
+ */
+ @Override
+ public V remove(Object key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Double,V>> entrySet() {
+ return new AbstractSet<Map.Entry<Double,V>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return TDoubleObjectHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TDoubleObjectHashMapDecorator.this.containsKey(k) &&
+ TDoubleObjectHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Double,V>> iterator() {
+ return new Iterator<Map.Entry<Double,V>>() {
+ private final TDoubleObjectIterator<V> it = _map.iterator();
+
+ @Override
+ public Map.Entry<Double,V> next() {
+ it.advance();
+ final Double key = wrapKey(it.key());
+ final V v = wrapValue(it.value());
+ return new Map.Entry<Double,V>() {
+ private V val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Double getKey() {
+ return key;
+ }
+
+ @Override
+ public V getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public V setValue(V value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Double,V> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Double,V>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TDoubleObjectHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue((V) val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Double, ? extends V> map) {
+ Iterator<? extends Entry<? extends Double,? extends V>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Double,? extends V> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Double wrapKey(double k) {
+ return new Double(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected double unwrapKey(Object key) {
+ return ((Double)key).doubleValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param o value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected final V wrapValue(V o) {
+ return o;
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected final V unwrapValue(V value) {
+ return value;
+ }
+
+} // TDoubleObjectHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatDoubleHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatDoubleHashMapDecorator.java
new file mode 100755
index 0000000..2decebe
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatDoubleHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TFloatDoubleHashMap;
+import gnu.trove.TFloatDoubleIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TFloatDoubleHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TFloatDoubleHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TFloatDoubleHashMapDecorator extends AbstractMap<Float, Double> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TFloatDoubleHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TFloatDoubleHashMapDecorator(TFloatDoubleHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Double(0) if none was found.
+ */
+ @Override
+ public Double put(Float key, Double value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Float && val instanceof Double) {
+ float k = unwrapKey(key);
+ double v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Double get(Object object) {
+ return get((Float)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Double get(Float key) {
+ float k = unwrapKey(key);
+ double v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Double(0) if it was not found in the map
+ */
+ public Double remove(Float key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Double remove(Object object) {
+ return remove((Double)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Float,Double>> entrySet() {
+ return new AbstractSet<Map.Entry<Float,Double>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TFloatDoubleHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TFloatDoubleHashMapDecorator.this.containsKey(k)
+ && TFloatDoubleHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Float,Double>> iterator() {
+ return new Iterator<Map.Entry<Float,Double>>() {
+ private final TFloatDoubleIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Float,Double> next() {
+ it.advance();
+ final Float key = wrapKey(it.key());
+ final Double v = wrapValue(it.value());
+ return new Map.Entry<Float,Double>() {
+ private Double val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Float getKey() {
+ return key;
+ }
+
+ @Override
+ public Double getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Double setValue(Double value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Float,Double> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Float, Double>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TFloatDoubleHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Float, ? extends Double> map) {
+ Iterator<? extends Entry<? extends Float,? extends Double>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Float,? extends Double> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Float wrapKey(float k) {
+ return new Float(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected float unwrapKey(Object key) {
+ return ((Float)key).floatValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Double wrapValue(double k) {
+ return new Double(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected double unwrapValue(Object value) {
+ return ((Double)value).doubleValue();
+ }
+
+} // TFloatDoubleHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatFloatHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatFloatHashMapDecorator.java
new file mode 100755
index 0000000..c4850b2
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatFloatHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TFloatFloatHashMap;
+import gnu.trove.TFloatFloatIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TFloatFloatHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TFloatFloatHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TFloatFloatHashMapDecorator extends AbstractMap<Float, Float> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TFloatFloatHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TFloatFloatHashMapDecorator(TFloatFloatHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Float(0) if none was found.
+ */
+ @Override
+ public Float put(Float key, Float value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Float && val instanceof Float) {
+ float k = unwrapKey(key);
+ float v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Float get(Object object) {
+ return get((Float)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Float get(Float key) {
+ float k = unwrapKey(key);
+ float v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Float(0) if it was not found in the map
+ */
+ public Float remove(Float key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Float remove(Object object) {
+ return remove((Float)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Float,Float>> entrySet() {
+ return new AbstractSet<Map.Entry<Float,Float>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TFloatFloatHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TFloatFloatHashMapDecorator.this.containsKey(k)
+ && TFloatFloatHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Float,Float>> iterator() {
+ return new Iterator<Map.Entry<Float,Float>>() {
+ private final TFloatFloatIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Float,Float> next() {
+ it.advance();
+ final Float key = wrapKey(it.key());
+ final Float v = wrapValue(it.value());
+ return new Map.Entry<Float,Float>() {
+ private Float val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Float getKey() {
+ return key;
+ }
+
+ @Override
+ public Float getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Float setValue(Float value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Float,Float> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Float, Float>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TFloatFloatHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Float, ? extends Float> map) {
+ Iterator<? extends Entry<? extends Float,? extends Float>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Float,? extends Float> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Float wrapKey(float k) {
+ return new Float(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected float unwrapKey(Object key) {
+ return ((Float)key).floatValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Float wrapValue(float k) {
+ return new Float(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected float unwrapValue(Object value) {
+ return ((Float)value).floatValue();
+ }
+
+} // TFloatFloatHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatHashSetDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatHashSetDecorator.java
new file mode 100755
index 0000000..5434579
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatHashSetDecorator.java
@@ -0,0 +1,189 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TFloatHashSet;
+import gnu.trove.TFloatIterator;
+
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TFloatHashSet conform to the <tt>java.util.Set</tt> API.
+ * This class simply decorates an underlying TFloatHashSet and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Tue Sep 24 22:08:17 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TFloatHashSetDecorator extends AbstractSet<Float> implements Set<Float> {
+ /**
+ * the wrapped primitive set
+ */
+ protected final TFloatHashSet _set;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive set.
+ */
+ public TFloatHashSetDecorator(TFloatHashSet set) {
+ super();
+ this._set = set;
+ }
+
+ /**
+ * Inserts a value into the set.
+ *
+ * @param value true if the set was modified by the insertion
+ */
+ @Override
+ public boolean add(Float value) {
+ return _set.add(unwrap(value));
+ }
+
+ /**
+ * Compares this set with another set for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the sets are identical
+ */
+ public boolean equals(Object other) {
+ if (_set.equals(other)) {
+ return true; // comparing two trove sets
+ } else if (other instanceof Set) {
+ Set that = (Set) other;
+ if (that.size() != _set.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Object val = it.next();
+ if (val instanceof Float) {
+ float v = unwrap(val);
+ if (_set.contains(v)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other set
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Empties the set.
+ */
+ @Override
+ public void clear() {
+ this._set.clear();
+ }
+
+ /**
+ * Deletes a value from the set.
+ *
+ * @param value an <code>Object</code> value
+ * @return true if the set was modified
+ */
+ @Override
+ public boolean remove(Object value) {
+ return _set.remove(unwrap(value));
+ }
+
+ /**
+ * Creates an iterator over the values of the set.
+ *
+ * @return an iterator with support for removals in the underlying set
+ */
+ @Override
+ public Iterator<Float> iterator() {
+ return new Iterator<Float>() {
+ private final TFloatIterator it = _set.iterator();
+
+ @Override
+ public Float next() {
+ return wrap(it.next());
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ /**
+ * Returns the number of entries in the set.
+ *
+ * @return the set's size.
+ */
+ @Override
+ public int size() {
+ return this._set.size();
+ }
+
+ /**
+ * Indicates whether set has any entries.
+ *
+ * @return true if the set is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying set
+ * @return an Object representation of the value
+ */
+ protected Float wrap(float k) {
+ return new Float(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected float unwrap(Object value) {
+ return ((Float) value).floatValue();
+ }
+} // TFloatHashSetDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatIntHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatIntHashMapDecorator.java
new file mode 100755
index 0000000..e27cff9
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatIntHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TFloatIntHashMap;
+import gnu.trove.TFloatIntIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TFloatIntHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TFloatIntHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TFloatIntHashMapDecorator extends AbstractMap<Float, Integer> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TFloatIntHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TFloatIntHashMapDecorator(TFloatIntHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Integer(0) if none was found.
+ */
+ @Override
+ public Integer put(Float key, Integer value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Float && val instanceof Integer) {
+ float k = unwrapKey(key);
+ int v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Integer get(Object object) {
+ return get((Float)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Integer get(Float key) {
+ float k = unwrapKey(key);
+ int v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Integer(0) if it was not found in the map
+ */
+ public Integer remove(Float key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Integer remove(Object object) {
+ return remove((Integer)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Float,Integer>> entrySet() {
+ return new AbstractSet<Map.Entry<Float,Integer>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TFloatIntHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TFloatIntHashMapDecorator.this.containsKey(k)
+ && TFloatIntHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Float,Integer>> iterator() {
+ return new Iterator<Map.Entry<Float,Integer>>() {
+ private final TFloatIntIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Float,Integer> next() {
+ it.advance();
+ final Float key = wrapKey(it.key());
+ final Integer v = wrapValue(it.value());
+ return new Map.Entry<Float,Integer>() {
+ private Integer val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Float getKey() {
+ return key;
+ }
+
+ @Override
+ public Integer getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Integer setValue(Integer value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Float,Integer> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Float, Integer>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TFloatIntHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Float, ? extends Integer> map) {
+ Iterator<? extends Entry<? extends Float,? extends Integer>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Float,? extends Integer> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Float wrapKey(float k) {
+ return new Float(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected float unwrapKey(Object key) {
+ return ((Float)key).floatValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Integer wrapValue(int k) {
+ return new Integer(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected int unwrapValue(Object value) {
+ return ((Integer)value).intValue();
+ }
+
+} // TFloatIntHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatLongHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatLongHashMapDecorator.java
new file mode 100755
index 0000000..f0fbfe1
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatLongHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TFloatLongHashMap;
+import gnu.trove.TFloatLongIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TFloatLongHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TFloatLongHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TFloatLongHashMapDecorator extends AbstractMap<Float, Long> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TFloatLongHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TFloatLongHashMapDecorator(TFloatLongHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Long(0) if none was found.
+ */
+ @Override
+ public Long put(Float key, Long value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Float && val instanceof Long) {
+ float k = unwrapKey(key);
+ long v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Long get(Object object) {
+ return get((Float)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Long get(Float key) {
+ float k = unwrapKey(key);
+ long v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Long(0) if it was not found in the map
+ */
+ public Long remove(Float key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Long remove(Object object) {
+ return remove((Long)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Float,Long>> entrySet() {
+ return new AbstractSet<Map.Entry<Float,Long>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TFloatLongHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TFloatLongHashMapDecorator.this.containsKey(k)
+ && TFloatLongHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Float,Long>> iterator() {
+ return new Iterator<Map.Entry<Float,Long>>() {
+ private final TFloatLongIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Float,Long> next() {
+ it.advance();
+ final Float key = wrapKey(it.key());
+ final Long v = wrapValue(it.value());
+ return new Map.Entry<Float,Long>() {
+ private Long val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Float getKey() {
+ return key;
+ }
+
+ @Override
+ public Long getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Long setValue(Long value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Float,Long> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Float, Long>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TFloatLongHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Float, ? extends Long> map) {
+ Iterator<? extends Entry<? extends Float,? extends Long>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Float,? extends Long> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Float wrapKey(float k) {
+ return new Float(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected float unwrapKey(Object key) {
+ return ((Float)key).floatValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Long wrapValue(long k) {
+ return new Long(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected long unwrapValue(Object value) {
+ return ((Long)value).longValue();
+ }
+
+} // TFloatLongHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatObjectHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatObjectHashMapDecorator.java
new file mode 100755
index 0000000..04dec07
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TFloatObjectHashMapDecorator.java
@@ -0,0 +1,360 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TFloatObjectHashMap;
+import gnu.trove.TFloatObjectIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TFloatObjectHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TFloatObjectHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TFloatObjectHashMapDecorator <V> extends AbstractMap<Float, V> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TFloatObjectHashMap<V> _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TFloatObjectHashMapDecorator(TFloatObjectHashMap<V> map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Integer(0) if none was found.
+ */
+ @Override
+ public V put(Float key, V value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Float) {
+ float k = unwrapKey(key);
+ Object v = unwrapValue((V) val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ @Override
+ public V get(Object key) {
+ return _map.get(unwrapKey(key));
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Integer(0) if it was not found in the map
+ */
+ @Override
+ public V remove(Object key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Float,V>> entrySet() {
+ return new AbstractSet<Map.Entry<Float,V>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return TFloatObjectHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TFloatObjectHashMapDecorator.this.containsKey(k) &&
+ TFloatObjectHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Float,V>> iterator() {
+ return new Iterator<Map.Entry<Float,V>>() {
+ private final TFloatObjectIterator<V> it = _map.iterator();
+
+ @Override
+ public Map.Entry<Float,V> next() {
+ it.advance();
+ final Float key = wrapKey(it.key());
+ final V v = wrapValue(it.value());
+ return new Map.Entry<Float,V>() {
+ private V val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Float getKey() {
+ return key;
+ }
+
+ @Override
+ public V getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public V setValue(V value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Float,V> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Float,V>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TFloatObjectHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue((V) val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Float, ? extends V> map) {
+ Iterator<? extends Entry<? extends Float,? extends V>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Float,? extends V> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Float wrapKey(float k) {
+ return new Float(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected float unwrapKey(Object key) {
+ return ((Float)key).floatValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param o value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected final V wrapValue(V o) {
+ return o;
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected final V unwrapValue(V value) {
+ return value;
+ }
+
+} // TFloatObjectHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntDoubleHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntDoubleHashMapDecorator.java
new file mode 100755
index 0000000..5a280fd
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntDoubleHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TIntDoubleHashMap;
+import gnu.trove.TIntDoubleIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TIntDoubleHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TIntDoubleHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TIntDoubleHashMapDecorator extends AbstractMap<Integer, Double> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TIntDoubleHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TIntDoubleHashMapDecorator(TIntDoubleHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Double(0) if none was found.
+ */
+ @Override
+ public Double put(Integer key, Double value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Integer && val instanceof Double) {
+ int k = unwrapKey(key);
+ double v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Double get(Object object) {
+ return get((Integer)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Double get(Integer key) {
+ int k = unwrapKey(key);
+ double v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Double(0) if it was not found in the map
+ */
+ public Double remove(Integer key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Double remove(Object object) {
+ return remove((Double)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Integer,Double>> entrySet() {
+ return new AbstractSet<Map.Entry<Integer,Double>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TIntDoubleHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TIntDoubleHashMapDecorator.this.containsKey(k)
+ && TIntDoubleHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Integer,Double>> iterator() {
+ return new Iterator<Map.Entry<Integer,Double>>() {
+ private final TIntDoubleIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Integer,Double> next() {
+ it.advance();
+ final Integer key = wrapKey(it.key());
+ final Double v = wrapValue(it.value());
+ return new Map.Entry<Integer,Double>() {
+ private Double val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Integer getKey() {
+ return key;
+ }
+
+ @Override
+ public Double getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Double setValue(Double value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Integer,Double> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Integer, Double>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TIntDoubleHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Integer, ? extends Double> map) {
+ Iterator<? extends Entry<? extends Integer,? extends Double>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Integer,? extends Double> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Integer wrapKey(int k) {
+ return new Integer(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected int unwrapKey(Object key) {
+ return ((Integer)key).intValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Double wrapValue(double k) {
+ return new Double(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected double unwrapValue(Object value) {
+ return ((Double)value).doubleValue();
+ }
+
+} // TIntDoubleHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntFloatHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntFloatHashMapDecorator.java
new file mode 100755
index 0000000..59657ed
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntFloatHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TIntFloatHashMap;
+import gnu.trove.TIntFloatIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TIntFloatHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TIntFloatHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TIntFloatHashMapDecorator extends AbstractMap<Integer, Float> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TIntFloatHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TIntFloatHashMapDecorator(TIntFloatHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Float(0) if none was found.
+ */
+ @Override
+ public Float put(Integer key, Float value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Integer && val instanceof Float) {
+ int k = unwrapKey(key);
+ float v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Float get(Object object) {
+ return get((Integer)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Float get(Integer key) {
+ int k = unwrapKey(key);
+ float v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Float(0) if it was not found in the map
+ */
+ public Float remove(Integer key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Float remove(Object object) {
+ return remove((Float)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Integer,Float>> entrySet() {
+ return new AbstractSet<Map.Entry<Integer,Float>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TIntFloatHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TIntFloatHashMapDecorator.this.containsKey(k)
+ && TIntFloatHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Integer,Float>> iterator() {
+ return new Iterator<Map.Entry<Integer,Float>>() {
+ private final TIntFloatIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Integer,Float> next() {
+ it.advance();
+ final Integer key = wrapKey(it.key());
+ final Float v = wrapValue(it.value());
+ return new Map.Entry<Integer,Float>() {
+ private Float val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Integer getKey() {
+ return key;
+ }
+
+ @Override
+ public Float getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Float setValue(Float value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Integer,Float> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Integer, Float>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TIntFloatHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Integer, ? extends Float> map) {
+ Iterator<? extends Entry<? extends Integer,? extends Float>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Integer,? extends Float> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Integer wrapKey(int k) {
+ return new Integer(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected int unwrapKey(Object key) {
+ return ((Integer)key).intValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Float wrapValue(float k) {
+ return new Float(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected float unwrapValue(Object value) {
+ return ((Float)value).floatValue();
+ }
+
+} // TIntFloatHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntHashSetDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntHashSetDecorator.java
new file mode 100755
index 0000000..340a13e
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntHashSetDecorator.java
@@ -0,0 +1,189 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TIntHashSet;
+import gnu.trove.TIntIterator;
+
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TIntHashSet conform to the <tt>java.util.Set</tt> API.
+ * This class simply decorates an underlying TIntHashSet and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Tue Sep 24 22:08:17 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TIntHashSetDecorator extends AbstractSet<Integer> implements Set<Integer> {
+ /**
+ * the wrapped primitive set
+ */
+ protected final TIntHashSet _set;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive set.
+ */
+ public TIntHashSetDecorator(TIntHashSet set) {
+ super();
+ this._set = set;
+ }
+
+ /**
+ * Inserts a value into the set.
+ *
+ * @param value true if the set was modified by the insertion
+ */
+ @Override
+ public boolean add(Integer value) {
+ return _set.add(unwrap(value));
+ }
+
+ /**
+ * Compares this set with another set for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the sets are identical
+ */
+ public boolean equals(Object other) {
+ if (_set.equals(other)) {
+ return true; // comparing two trove sets
+ } else if (other instanceof Set) {
+ Set that = (Set) other;
+ if (that.size() != _set.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Object val = it.next();
+ if (val instanceof Integer) {
+ int v = unwrap(val);
+ if (_set.contains(v)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other set
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Empties the set.
+ */
+ @Override
+ public void clear() {
+ this._set.clear();
+ }
+
+ /**
+ * Deletes a value from the set.
+ *
+ * @param value an <code>Object</code> value
+ * @return true if the set was modified
+ */
+ @Override
+ public boolean remove(Object value) {
+ return _set.remove(unwrap(value));
+ }
+
+ /**
+ * Creates an iterator over the values of the set.
+ *
+ * @return an iterator with support for removals in the underlying set
+ */
+ @Override
+ public Iterator<Integer> iterator() {
+ return new Iterator<Integer>() {
+ private final TIntIterator it = _set.iterator();
+
+ @Override
+ public Integer next() {
+ return wrap(it.next());
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ /**
+ * Returns the number of entries in the set.
+ *
+ * @return the set's size.
+ */
+ @Override
+ public int size() {
+ return this._set.size();
+ }
+
+ /**
+ * Indicates whether set has any entries.
+ *
+ * @return true if the set is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying set
+ * @return an Object representation of the value
+ */
+ protected Integer wrap(int k) {
+ return new Integer(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected int unwrap(Object value) {
+ return ((Integer) value).intValue();
+ }
+} // TIntHashSetDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntIntHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntIntHashMapDecorator.java
new file mode 100755
index 0000000..a628893
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntIntHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TIntIntHashMap;
+import gnu.trove.TIntIntIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TIntIntHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TIntIntHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TIntIntHashMapDecorator extends AbstractMap<Integer, Integer> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TIntIntHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TIntIntHashMapDecorator(TIntIntHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Integer(0) if none was found.
+ */
+ @Override
+ public Integer put(Integer key, Integer value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Integer && val instanceof Integer) {
+ int k = unwrapKey(key);
+ int v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Integer get(Object object) {
+ return get((Integer)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Integer get(Integer key) {
+ int k = unwrapKey(key);
+ int v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Integer(0) if it was not found in the map
+ */
+ public Integer remove(Integer key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Integer remove(Object object) {
+ return remove((Integer)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Integer,Integer>> entrySet() {
+ return new AbstractSet<Map.Entry<Integer,Integer>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TIntIntHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TIntIntHashMapDecorator.this.containsKey(k)
+ && TIntIntHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Integer,Integer>> iterator() {
+ return new Iterator<Map.Entry<Integer,Integer>>() {
+ private final TIntIntIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Integer,Integer> next() {
+ it.advance();
+ final Integer key = wrapKey(it.key());
+ final Integer v = wrapValue(it.value());
+ return new Map.Entry<Integer,Integer>() {
+ private Integer val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Integer getKey() {
+ return key;
+ }
+
+ @Override
+ public Integer getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Integer setValue(Integer value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Integer,Integer> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Integer, Integer>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TIntIntHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Integer, ? extends Integer> map) {
+ Iterator<? extends Entry<? extends Integer,? extends Integer>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Integer,? extends Integer> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Integer wrapKey(int k) {
+ return new Integer(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected int unwrapKey(Object key) {
+ return ((Integer)key).intValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Integer wrapValue(int k) {
+ return new Integer(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected int unwrapValue(Object value) {
+ return ((Integer)value).intValue();
+ }
+
+} // TIntIntHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntLongHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntLongHashMapDecorator.java
new file mode 100755
index 0000000..562b777
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntLongHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TIntLongHashMap;
+import gnu.trove.TIntLongIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TIntLongHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TIntLongHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TIntLongHashMapDecorator extends AbstractMap<Integer, Long> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TIntLongHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TIntLongHashMapDecorator(TIntLongHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Long(0) if none was found.
+ */
+ @Override
+ public Long put(Integer key, Long value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Integer && val instanceof Long) {
+ int k = unwrapKey(key);
+ long v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Long get(Object object) {
+ return get((Integer)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Long get(Integer key) {
+ int k = unwrapKey(key);
+ long v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Long(0) if it was not found in the map
+ */
+ public Long remove(Integer key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Long remove(Object object) {
+ return remove((Long)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Integer,Long>> entrySet() {
+ return new AbstractSet<Map.Entry<Integer,Long>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TIntLongHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TIntLongHashMapDecorator.this.containsKey(k)
+ && TIntLongHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Integer,Long>> iterator() {
+ return new Iterator<Map.Entry<Integer,Long>>() {
+ private final TIntLongIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Integer,Long> next() {
+ it.advance();
+ final Integer key = wrapKey(it.key());
+ final Long v = wrapValue(it.value());
+ return new Map.Entry<Integer,Long>() {
+ private Long val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Integer getKey() {
+ return key;
+ }
+
+ @Override
+ public Long getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Long setValue(Long value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Integer,Long> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Integer, Long>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TIntLongHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Integer, ? extends Long> map) {
+ Iterator<? extends Entry<? extends Integer,? extends Long>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Integer,? extends Long> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Integer wrapKey(int k) {
+ return new Integer(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected int unwrapKey(Object key) {
+ return ((Integer)key).intValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Long wrapValue(long k) {
+ return new Long(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected long unwrapValue(Object value) {
+ return ((Long)value).longValue();
+ }
+
+} // TIntLongHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntObjectHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntObjectHashMapDecorator.java
new file mode 100755
index 0000000..ef14422
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TIntObjectHashMapDecorator.java
@@ -0,0 +1,360 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TIntObjectHashMap;
+import gnu.trove.TIntObjectIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TIntObjectHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TIntObjectHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TIntObjectHashMapDecorator <V> extends AbstractMap<Integer, V> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TIntObjectHashMap<V> _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TIntObjectHashMapDecorator(TIntObjectHashMap<V> map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Integer(0) if none was found.
+ */
+ @Override
+ public V put(Integer key, V value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Integer) {
+ int k = unwrapKey(key);
+ Object v = unwrapValue((V) val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ @Override
+ public V get(Object key) {
+ return _map.get(unwrapKey(key));
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Integer(0) if it was not found in the map
+ */
+ @Override
+ public V remove(Object key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Integer,V>> entrySet() {
+ return new AbstractSet<Map.Entry<Integer,V>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return TIntObjectHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TIntObjectHashMapDecorator.this.containsKey(k) &&
+ TIntObjectHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Integer,V>> iterator() {
+ return new Iterator<Map.Entry<Integer,V>>() {
+ private final TIntObjectIterator<V> it = _map.iterator();
+
+ @Override
+ public Map.Entry<Integer,V> next() {
+ it.advance();
+ final Integer key = wrapKey(it.key());
+ final V v = wrapValue(it.value());
+ return new Map.Entry<Integer,V>() {
+ private V val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Integer getKey() {
+ return key;
+ }
+
+ @Override
+ public V getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public V setValue(V value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Integer,V> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Integer,V>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TIntObjectHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue((V) val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Integer, ? extends V> map) {
+ Iterator<? extends Entry<? extends Integer,? extends V>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Integer,? extends V> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Integer wrapKey(int k) {
+ return new Integer(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected int unwrapKey(Object key) {
+ return ((Integer)key).intValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param o value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected final V wrapValue(V o) {
+ return o;
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected final V unwrapValue(V value) {
+ return value;
+ }
+
+} // TIntObjectHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongDoubleHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongDoubleHashMapDecorator.java
new file mode 100755
index 0000000..6642760
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongDoubleHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TLongDoubleHashMap;
+import gnu.trove.TLongDoubleIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TLongDoubleHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TLongDoubleHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TLongDoubleHashMapDecorator extends AbstractMap<Long, Double> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TLongDoubleHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TLongDoubleHashMapDecorator(TLongDoubleHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Double(0) if none was found.
+ */
+ @Override
+ public Double put(Long key, Double value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Long && val instanceof Double) {
+ long k = unwrapKey(key);
+ double v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Double get(Object object) {
+ return get((Long)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Double get(Long key) {
+ long k = unwrapKey(key);
+ double v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Double(0) if it was not found in the map
+ */
+ public Double remove(Long key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Double remove(Object object) {
+ return remove((Double)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Long,Double>> entrySet() {
+ return new AbstractSet<Map.Entry<Long,Double>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TLongDoubleHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TLongDoubleHashMapDecorator.this.containsKey(k)
+ && TLongDoubleHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Long,Double>> iterator() {
+ return new Iterator<Map.Entry<Long,Double>>() {
+ private final TLongDoubleIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Long,Double> next() {
+ it.advance();
+ final Long key = wrapKey(it.key());
+ final Double v = wrapValue(it.value());
+ return new Map.Entry<Long,Double>() {
+ private Double val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Long getKey() {
+ return key;
+ }
+
+ @Override
+ public Double getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Double setValue(Double value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Long,Double> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Long, Double>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TLongDoubleHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Long, ? extends Double> map) {
+ Iterator<? extends Entry<? extends Long,? extends Double>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Long,? extends Double> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Long wrapKey(long k) {
+ return new Long(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected long unwrapKey(Object key) {
+ return ((Long)key).longValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Double wrapValue(double k) {
+ return new Double(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected double unwrapValue(Object value) {
+ return ((Double)value).doubleValue();
+ }
+
+} // TLongDoubleHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongFloatHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongFloatHashMapDecorator.java
new file mode 100755
index 0000000..141fa4a
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongFloatHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TLongFloatHashMap;
+import gnu.trove.TLongFloatIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TLongFloatHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TLongFloatHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TLongFloatHashMapDecorator extends AbstractMap<Long, Float> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TLongFloatHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TLongFloatHashMapDecorator(TLongFloatHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Float(0) if none was found.
+ */
+ @Override
+ public Float put(Long key, Float value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Long && val instanceof Float) {
+ long k = unwrapKey(key);
+ float v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Float get(Object object) {
+ return get((Long)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Float get(Long key) {
+ long k = unwrapKey(key);
+ float v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Float(0) if it was not found in the map
+ */
+ public Float remove(Long key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Float remove(Object object) {
+ return remove((Float)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Long,Float>> entrySet() {
+ return new AbstractSet<Map.Entry<Long,Float>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TLongFloatHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TLongFloatHashMapDecorator.this.containsKey(k)
+ && TLongFloatHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Long,Float>> iterator() {
+ return new Iterator<Map.Entry<Long,Float>>() {
+ private final TLongFloatIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Long,Float> next() {
+ it.advance();
+ final Long key = wrapKey(it.key());
+ final Float v = wrapValue(it.value());
+ return new Map.Entry<Long,Float>() {
+ private Float val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Long getKey() {
+ return key;
+ }
+
+ @Override
+ public Float getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Float setValue(Float value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Long,Float> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Long, Float>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TLongFloatHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Long, ? extends Float> map) {
+ Iterator<? extends Entry<? extends Long,? extends Float>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Long,? extends Float> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Long wrapKey(long k) {
+ return new Long(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected long unwrapKey(Object key) {
+ return ((Long)key).longValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Float wrapValue(float k) {
+ return new Float(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected float unwrapValue(Object value) {
+ return ((Float)value).floatValue();
+ }
+
+} // TLongFloatHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongHashSetDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongHashSetDecorator.java
new file mode 100755
index 0000000..908d95d
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongHashSetDecorator.java
@@ -0,0 +1,189 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TLongHashSet;
+import gnu.trove.TLongIterator;
+
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TLongHashSet conform to the <tt>java.util.Set</tt> API.
+ * This class simply decorates an underlying TLongHashSet and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Tue Sep 24 22:08:17 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TLongHashSetDecorator extends AbstractSet<Long> implements Set<Long> {
+ /**
+ * the wrapped primitive set
+ */
+ protected final TLongHashSet _set;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive set.
+ */
+ public TLongHashSetDecorator(TLongHashSet set) {
+ super();
+ this._set = set;
+ }
+
+ /**
+ * Inserts a value into the set.
+ *
+ * @param value true if the set was modified by the insertion
+ */
+ @Override
+ public boolean add(Long value) {
+ return _set.add(unwrap(value));
+ }
+
+ /**
+ * Compares this set with another set for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the sets are identical
+ */
+ public boolean equals(Object other) {
+ if (_set.equals(other)) {
+ return true; // comparing two trove sets
+ } else if (other instanceof Set) {
+ Set that = (Set) other;
+ if (that.size() != _set.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Object val = it.next();
+ if (val instanceof Long) {
+ long v = unwrap(val);
+ if (_set.contains(v)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other set
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Empties the set.
+ */
+ @Override
+ public void clear() {
+ this._set.clear();
+ }
+
+ /**
+ * Deletes a value from the set.
+ *
+ * @param value an <code>Object</code> value
+ * @return true if the set was modified
+ */
+ @Override
+ public boolean remove(Object value) {
+ return _set.remove(unwrap(value));
+ }
+
+ /**
+ * Creates an iterator over the values of the set.
+ *
+ * @return an iterator with support for removals in the underlying set
+ */
+ @Override
+ public Iterator<Long> iterator() {
+ return new Iterator<Long>() {
+ private final TLongIterator it = _set.iterator();
+
+ @Override
+ public Long next() {
+ return wrap(it.next());
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ /**
+ * Returns the number of entries in the set.
+ *
+ * @return the set's size.
+ */
+ @Override
+ public int size() {
+ return this._set.size();
+ }
+
+ /**
+ * Indicates whether set has any entries.
+ *
+ * @return true if the set is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying set
+ * @return an Object representation of the value
+ */
+ protected Long wrap(long k) {
+ return new Long(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected long unwrap(Object value) {
+ return ((Long) value).longValue();
+ }
+} // TLongHashSetDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongIntHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongIntHashMapDecorator.java
new file mode 100755
index 0000000..0ec86a3
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongIntHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TLongIntHashMap;
+import gnu.trove.TLongIntIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TLongIntHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TLongIntHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TLongIntHashMapDecorator extends AbstractMap<Long, Integer> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TLongIntHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TLongIntHashMapDecorator(TLongIntHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Integer(0) if none was found.
+ */
+ @Override
+ public Integer put(Long key, Integer value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Long && val instanceof Integer) {
+ long k = unwrapKey(key);
+ int v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Integer get(Object object) {
+ return get((Long)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Integer get(Long key) {
+ long k = unwrapKey(key);
+ int v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Integer(0) if it was not found in the map
+ */
+ public Integer remove(Long key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Integer remove(Object object) {
+ return remove((Integer)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Long,Integer>> entrySet() {
+ return new AbstractSet<Map.Entry<Long,Integer>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TLongIntHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TLongIntHashMapDecorator.this.containsKey(k)
+ && TLongIntHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Long,Integer>> iterator() {
+ return new Iterator<Map.Entry<Long,Integer>>() {
+ private final TLongIntIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Long,Integer> next() {
+ it.advance();
+ final Long key = wrapKey(it.key());
+ final Integer v = wrapValue(it.value());
+ return new Map.Entry<Long,Integer>() {
+ private Integer val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Long getKey() {
+ return key;
+ }
+
+ @Override
+ public Integer getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Integer setValue(Integer value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Long,Integer> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Long, Integer>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TLongIntHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Long, ? extends Integer> map) {
+ Iterator<? extends Entry<? extends Long,? extends Integer>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Long,? extends Integer> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Long wrapKey(long k) {
+ return new Long(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected long unwrapKey(Object key) {
+ return ((Long)key).longValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Integer wrapValue(int k) {
+ return new Integer(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected int unwrapValue(Object value) {
+ return ((Integer)value).intValue();
+ }
+
+} // TLongIntHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongLongHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongLongHashMapDecorator.java
new file mode 100755
index 0000000..981afcb
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongLongHashMapDecorator.java
@@ -0,0 +1,376 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TLongLongHashMap;
+import gnu.trove.TLongLongIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TLongLongHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TLongLongHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TLongLongHashMapDecorator extends AbstractMap<Long, Long> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TLongLongHashMap _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TLongLongHashMapDecorator(TLongLongHashMap map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Long(0) if none was found.
+ */
+ @Override
+ public Long put(Long key, Long value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Long && val instanceof Long) {
+ long k = unwrapKey(key);
+ long v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Long get(Object object) {
+ return get((Long)object);
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ public Long get(Long key) {
+ long k = unwrapKey(key);
+ long v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Long(0) if it was not found in the map
+ */
+ public Long remove(Long key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+ @Override
+ public Long remove(Object object) {
+ return remove((Long)object);
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Long,Long>> entrySet() {
+ return new AbstractSet<Map.Entry<Long,Long>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+ @Override
+ public boolean isEmpty() {
+ return TLongLongHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TLongLongHashMapDecorator.this.containsKey(k)
+ && TLongLongHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Long,Long>> iterator() {
+ return new Iterator<Map.Entry<Long,Long>>() {
+ private final TLongLongIterator it = _map.iterator();
+
+ @Override
+ public Map.Entry<Long,Long> next() {
+ it.advance();
+ final Long key = wrapKey(it.key());
+ final Long v = wrapValue(it.value());
+ return new Map.Entry<Long,Long>() {
+ private Long val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Long getKey() {
+ return key;
+ }
+
+ @Override
+ public Long getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Long setValue(Long value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Long,Long> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Long, Long>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TLongLongHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Long, ? extends Long> map) {
+ Iterator<? extends Entry<? extends Long,? extends Long>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Long,? extends Long> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Long wrapKey(long k) {
+ return new Long(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected long unwrapKey(Object key) {
+ return ((Long)key).longValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Long wrapValue(long k) {
+ return new Long(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected long unwrapValue(Object value) {
+ return ((Long)value).longValue();
+ }
+
+} // TLongLongHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongObjectHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongObjectHashMapDecorator.java
new file mode 100755
index 0000000..52f3303
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TLongObjectHashMapDecorator.java
@@ -0,0 +1,360 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TLongObjectHashMap;
+import gnu.trove.TLongObjectIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TLongObjectHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TLongObjectHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TLongObjectHashMapDecorator <V> extends AbstractMap<Long, V> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TLongObjectHashMap<V> _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TLongObjectHashMapDecorator(TLongObjectHashMap<V> map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Integer(0) if none was found.
+ */
+ @Override
+ public V put(Long key, V value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (key instanceof Long) {
+ long k = unwrapKey(key);
+ Object v = unwrapValue((V) val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ @Override
+ public V get(Object key) {
+ return _map.get(unwrapKey(key));
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Integer(0) if it was not found in the map
+ */
+ @Override
+ public V remove(Object key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<Long,V>> entrySet() {
+ return new AbstractSet<Map.Entry<Long,V>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return TLongObjectHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TLongObjectHashMapDecorator.this.containsKey(k) &&
+ TLongObjectHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<Long,V>> iterator() {
+ return new Iterator<Map.Entry<Long,V>>() {
+ private final TLongObjectIterator<V> it = _map.iterator();
+
+ @Override
+ public Map.Entry<Long,V> next() {
+ it.advance();
+ final Long key = wrapKey(it.key());
+ final V v = wrapValue(it.value());
+ return new Map.Entry<Long,V>() {
+ private V val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry
+ && ((Map.Entry) o).getKey().equals(key)
+ && ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public Long getKey() {
+ return key;
+ }
+
+ @Override
+ public V getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public V setValue(V value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<Long,V> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<Long,V>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TLongObjectHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue((V) val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends Long, ? extends V> map) {
+ Iterator<? extends Entry<? extends Long,? extends V>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends Long,? extends V> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param k key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected Long wrapKey(long k) {
+ return new Long(k);
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected long unwrapKey(Object key) {
+ return ((Long)key).longValue();
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param o value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected final V wrapValue(V o) {
+ return o;
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected final V unwrapValue(V value) {
+ return value;
+ }
+
+} // TLongObjectHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TObjectDoubleHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TObjectDoubleHashMapDecorator.java
new file mode 100755
index 0000000..d31f09d
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TObjectDoubleHashMapDecorator.java
@@ -0,0 +1,370 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TObjectDoubleHashMap;
+import gnu.trove.TObjectDoubleIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TObjectDoubleHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TObjectDoubleHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TObjectDoubleHashMapDecorator<V> extends AbstractMap<V, Double> implements Map<V, Double> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TObjectDoubleHashMap<V> _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TObjectDoubleHashMapDecorator(TObjectDoubleHashMap<V> map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Integer(0) if none was found.
+ */
+ @Override
+ public Double put(V key, Double value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (val instanceof Double) {
+ V k = unwrapKey(key);
+ double v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ @Override
+ public Double get(Object key) {
+ V k = unwrapKey(key);
+ double v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Integer(0) if it was not found in the map
+ */
+ @Override
+ public Double remove(Object key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<V,Double>> entrySet() {
+ return new AbstractSet<Map.Entry<V,Double>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return TObjectDoubleHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TObjectDoubleHashMapDecorator.this.containsKey(k) &&
+ TObjectDoubleHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<V,Double>> iterator() {
+ return new Iterator<Map.Entry<V,Double>>() {
+ private final TObjectDoubleIterator<V> it = _map.iterator();
+
+ @Override
+ public Map.Entry<V,Double> next() {
+ it.advance();
+ final V key = wrapKey(it.key());
+ final Double v = wrapValue(it.value());
+ return new Map.Entry<V,Double>() {
+ private Double val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry &&
+ ((Map.Entry) o).getKey().equals(key) &&
+ ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public V getKey() {
+ return key;
+ }
+
+ @Override
+ public Double getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Double setValue(Double value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<V,Double> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<V,Double>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TObjectDoubleHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends V, ? extends Double> map) {
+ Iterator<? extends Entry<? extends V,? extends Double>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends V,? extends Double> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param o key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected final V wrapKey(Object o) {
+ return (V) o;
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected final V unwrapKey(Object key) {
+ return (V) key;
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Double wrapValue(double k) {
+ return new Double(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected double unwrapValue(Object value) {
+ return ((Double) value).doubleValue();
+ }
+
+} // TObjectDoubleHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TObjectFloatHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TObjectFloatHashMapDecorator.java
new file mode 100755
index 0000000..9964046
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TObjectFloatHashMapDecorator.java
@@ -0,0 +1,370 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TObjectFloatHashMap;
+import gnu.trove.TObjectFloatIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TObjectFloatHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TObjectFloatHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TObjectFloatHashMapDecorator<V> extends AbstractMap<V, Float> implements Map<V, Float> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TObjectFloatHashMap<V> _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TObjectFloatHashMapDecorator(TObjectFloatHashMap<V> map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Integer(0) if none was found.
+ */
+ @Override
+ public Float put(V key, Float value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (val instanceof Float) {
+ V k = unwrapKey(key);
+ float v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ @Override
+ public Float get(Object key) {
+ V k = unwrapKey(key);
+ float v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Integer(0) if it was not found in the map
+ */
+ @Override
+ public Float remove(Object key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<V,Float>> entrySet() {
+ return new AbstractSet<Map.Entry<V,Float>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return TObjectFloatHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TObjectFloatHashMapDecorator.this.containsKey(k) &&
+ TObjectFloatHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<V,Float>> iterator() {
+ return new Iterator<Map.Entry<V,Float>>() {
+ private final TObjectFloatIterator<V> it = _map.iterator();
+
+ @Override
+ public Map.Entry<V,Float> next() {
+ it.advance();
+ final V key = wrapKey(it.key());
+ final Float v = wrapValue(it.value());
+ return new Map.Entry<V,Float>() {
+ private Float val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry &&
+ ((Map.Entry) o).getKey().equals(key) &&
+ ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public V getKey() {
+ return key;
+ }
+
+ @Override
+ public Float getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Float setValue(Float value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<V,Float> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<V,Float>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TObjectFloatHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends V, ? extends Float> map) {
+ Iterator<? extends Entry<? extends V,? extends Float>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends V,? extends Float> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param o key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected final V wrapKey(Object o) {
+ return (V) o;
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected final V unwrapKey(Object key) {
+ return (V) key;
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Float wrapValue(float k) {
+ return new Float(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected float unwrapValue(Object value) {
+ return ((Float) value).floatValue();
+ }
+
+} // TObjectFloatHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TObjectIntHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TObjectIntHashMapDecorator.java
new file mode 100755
index 0000000..938b3eb
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TObjectIntHashMapDecorator.java
@@ -0,0 +1,370 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TObjectIntHashMap;
+import gnu.trove.TObjectIntIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TObjectIntHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TObjectIntHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TObjectIntHashMapDecorator<V> extends AbstractMap<V, Integer> implements Map<V, Integer> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TObjectIntHashMap<V> _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TObjectIntHashMapDecorator(TObjectIntHashMap<V> map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Integer(0) if none was found.
+ */
+ @Override
+ public Integer put(V key, Integer value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (val instanceof Integer) {
+ V k = unwrapKey(key);
+ int v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ @Override
+ public Integer get(Object key) {
+ V k = unwrapKey(key);
+ int v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Integer(0) if it was not found in the map
+ */
+ @Override
+ public Integer remove(Object key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<V,Integer>> entrySet() {
+ return new AbstractSet<Map.Entry<V,Integer>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return TObjectIntHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TObjectIntHashMapDecorator.this.containsKey(k) &&
+ TObjectIntHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<V,Integer>> iterator() {
+ return new Iterator<Map.Entry<V,Integer>>() {
+ private final TObjectIntIterator<V> it = _map.iterator();
+
+ @Override
+ public Map.Entry<V,Integer> next() {
+ it.advance();
+ final V key = wrapKey(it.key());
+ final Integer v = wrapValue(it.value());
+ return new Map.Entry<V,Integer>() {
+ private Integer val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry &&
+ ((Map.Entry) o).getKey().equals(key) &&
+ ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public V getKey() {
+ return key;
+ }
+
+ @Override
+ public Integer getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Integer setValue(Integer value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<V,Integer> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<V,Integer>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TObjectIntHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends V, ? extends Integer> map) {
+ Iterator<? extends Entry<? extends V,? extends Integer>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends V,? extends Integer> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param o key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected final V wrapKey(Object o) {
+ return (V) o;
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected final V unwrapKey(Object key) {
+ return (V) key;
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Integer wrapValue(int k) {
+ return new Integer(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected int unwrapValue(Object value) {
+ return ((Integer) value).intValue();
+ }
+
+} // TObjectIntHashMapDecorator
diff --git a/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TObjectLongHashMapDecorator.java b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TObjectLongHashMapDecorator.java
new file mode 100755
index 0000000..e591293
--- /dev/null
+++ b/trove/trove4j-1.1-sources.jar-unzipped_flattened/decorator/TObjectLongHashMapDecorator.java
@@ -0,0 +1,370 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS AUTOGENERATED, PLEASE DO NOT EDIT OR ELSE
+package gnu.trove.decorator;
+
+import gnu.trove.TObjectLongHashMap;
+import gnu.trove.TObjectLongIterator;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper class to make a TObjectLongHashMap conform to the <tt>java.util.Map</tt> API.
+ * This class simply decorates an underlying TObjectLongHashMap and translates the Object-based
+ * APIs into their Trove primitive analogs.
+ * <p/>
+ * <p/>
+ * Note that wrapping and unwrapping primitive values is extremely inefficient. If
+ * possible, users of this class should override the appropriate methods in this class
+ * and use a table of canonical values.
+ * </p>
+ * <p/>
+ * Created: Mon Sep 23 22:07:40 PDT 2002
+ *
+ * @author Eric D. Friedman
+ * @since trove 0.1.8
+ */
+public class TObjectLongHashMapDecorator<V> extends AbstractMap<V, Long> implements Map<V, Long> {
+ /**
+ * the wrapped primitive map
+ */
+ protected final TObjectLongHashMap<V> _map;
+
+ /**
+ * Creates a wrapper that decorates the specified primitive map.
+ */
+ public TObjectLongHashMapDecorator(TObjectLongHashMap<V> map) {
+ super();
+ this._map = map;
+ }
+
+ /**
+ * Inserts a key/value pair into the map.
+ *
+ * @param key an <code>Object</code> value
+ * @param value an <code>Object</code> value
+ * @return the previous value associated with <tt>key</tt>,
+ * or Integer(0) if none was found.
+ */
+ @Override
+ public Long put(V key, Long value) {
+ return wrapValue(_map.put(unwrapKey(key), unwrapValue(value)));
+ }
+
+ /**
+ * Compares this map with another map for equality of their stored
+ * entries.
+ *
+ * @param other an <code>Object</code> value
+ * @return true if the maps are identical
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (_map.equals(other)) {
+ return true; // comparing two trove maps
+ } else if (other instanceof Map) {
+ Map that = (Map) other;
+ if (that.size() != _map.size()) {
+ return false; // different sizes, no need to compare
+ } else { // now we have to do it the hard way
+ Iterator it = that.entrySet().iterator();
+ for (int i = that.size(); i-- > 0;) {
+ Map.Entry e = (Map.Entry) it.next();
+ Object key = e.getKey();
+ Object val = e.getValue();
+ if (val instanceof Long) {
+ V k = unwrapKey(key);
+ long v = unwrapValue(val);
+ if (_map.containsKey(k) && v == _map.get(k)) {
+ // match, ok to continue
+ } else {
+ return false; // no match: we're done
+ }
+ } else {
+ return false; // different type in other map
+ }
+ }
+ return true; // all entries match
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Retrieves the value for <tt>key</tt>
+ *
+ * @param key an <code>Object</code> value
+ * @return the value of <tt>key</tt> or null if no such mapping exists.
+ */
+ @Override
+ public Long get(Object key) {
+ V k = unwrapKey(key);
+ long v = _map.get(k);
+ // 0 may be a false positive since primitive maps
+ // cannot return null, so we have to do an extra
+ // check here.
+ if (v == 0) {
+ return _map.containsKey(k) ? wrapValue(v) : null;
+ } else {
+ return wrapValue(v);
+ }
+ }
+
+
+ /**
+ * Empties the map.
+ */
+ @Override
+ public void clear() {
+ this._map.clear();
+ }
+
+ /**
+ * Deletes a key/value pair from the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return the removed value, or Integer(0) if it was not found in the map
+ */
+ @Override
+ public Long remove(Object key) {
+ return wrapValue(_map.remove(unwrapKey(key)));
+ }
+
+ /**
+ * Returns a Set view on the entries of the map.
+ *
+ * @return a <code>Set</code> value
+ */
+ @Override
+ public Set<Map.Entry<V,Long>> entrySet() {
+ return new AbstractSet<Map.Entry<V,Long>>() {
+ @Override
+ public int size() {
+ return _map.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return TObjectLongHashMapDecorator.this.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof Map.Entry) {
+ Object k = ((Map.Entry) o).getKey();
+ Object v = ((Map.Entry) o).getValue();
+ return TObjectLongHashMapDecorator.this.containsKey(k) &&
+ TObjectLongHashMapDecorator.this.get(k).equals(v);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Iterator<Map.Entry<V,Long>> iterator() {
+ return new Iterator<Map.Entry<V,Long>>() {
+ private final TObjectLongIterator<V> it = _map.iterator();
+
+ @Override
+ public Map.Entry<V,Long> next() {
+ it.advance();
+ final V key = wrapKey(it.key());
+ final Long v = wrapValue(it.value());
+ return new Map.Entry<V,Long>() {
+ private Long val = v;
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof Map.Entry &&
+ ((Map.Entry) o).getKey().equals(key) &&
+ ((Map.Entry) o).getValue().equals(val);
+ }
+
+ @Override
+ public V getKey() {
+ return key;
+ }
+
+ @Override
+ public Long getValue() {
+ return val;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() + val.hashCode();
+ }
+
+ @Override
+ public Long setValue(Long value) {
+ val = value;
+ return put(key, value);
+ }
+ };
+ }
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public void remove() {
+ it.remove();
+ }
+ };
+ }
+
+ @Override
+ public boolean add(Map.Entry<V,Long> o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Map.Entry<V,Long>> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ TObjectLongHashMapDecorator.this.clear();
+ }
+ };
+ }
+
+ /**
+ * Checks for the presence of <tt>val</tt> in the values of the map.
+ *
+ * @param val an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsValue(Object val) {
+ return _map.containsValue(unwrapValue(val));
+ }
+
+ /**
+ * Checks for the present of <tt>key</tt> in the keys of the map.
+ *
+ * @param key an <code>Object</code> value
+ * @return a <code>boolean</code> value
+ */
+ @Override
+ public boolean containsKey(Object key) {
+ return _map.containsKey(unwrapKey(key));
+ }
+
+ /**
+ * Returns the number of entries in the map.
+ *
+ * @return the map's size.
+ */
+ @Override
+ public int size() {
+ return this._map.size();
+ }
+
+ /**
+ * Indicates whether map has any entries.
+ *
+ * @return true if the map is empty
+ */
+ @Override
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Copies the key/value mappings in <tt>map</tt> into this map.
+ * Note that this will be a <b>deep</b> copy, as storage is by
+ * primitive value.
+ *
+ * @param map a <code>Map</code> value
+ */
+ @Override
+ public void putAll(Map<? extends V, ? extends Long> map) {
+ Iterator<? extends Entry<? extends V,? extends Long>> it = map.entrySet().iterator();
+ for (int i = map.size(); i-- > 0;) {
+ Entry<? extends V,? extends Long> e = it.next();
+ this.put(e.getKey(), e.getValue());
+ }
+ }
+
+ /**
+ * Wraps a key
+ *
+ * @param o key in the underlying map
+ * @return an Object representation of the key
+ */
+ protected final V wrapKey(Object o) {
+ return (V) o;
+ }
+
+ /**
+ * Unwraps a key
+ *
+ * @param key wrapped key
+ * @return an unwrapped representation of the key
+ */
+ protected final V unwrapKey(Object key) {
+ return (V) key;
+ }
+
+ /**
+ * Wraps a value
+ *
+ * @param k value in the underlying map
+ * @return an Object representation of the value
+ */
+ protected Long wrapValue(long k) {
+ return new Long(k);
+ }
+
+ /**
+ * Unwraps a value
+ *
+ * @param value wrapped value
+ * @return an unwrapped representation of the value
+ */
+ protected long unwrapValue(Object value) {
+ return ((Long) value).longValue();
+ }
+
+} // TObjectLongHashMapDecorator