Skip to content

Commit

Permalink
Tidying up and converting to a maven project.
Browse files Browse the repository at this point in the history
  • Loading branch information
reines committed Jun 2, 2011
1 parent b1b87ac commit 1b31016
Show file tree
Hide file tree
Showing 27 changed files with 61 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.classpath
.settings
.project
bin/
/.classpath
/.settings
/bin/
/target/
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>persistenthashmap</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Binary file removed lib/gson-1.4.jar
Binary file not shown.
Binary file removed lib/xpp3_min-1.1.4c.jar
Binary file not shown.
Binary file removed lib/xstream-1.3.1.jar
Binary file not shown.
23 changes: 23 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jamierf</groupId>
<artifactId>persistenthashmap</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3_min</artifactId>
<version>1.1.4c</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
*
*
* This file is part of the Persistent-HashMap library.
* Copyright (C) 2010 Jamie Furness (http://www.jamierf.co.uk)
* License: http://www.gnu.org/licenses/gpl.html GPL version 3 (or higher)
*
*
*/

package com.jamierf.persistenthashmap;
Expand All @@ -25,27 +25,29 @@ public CachedPersistentHashMap(File root) {
this (root, new OOSSerializer());
}

@SuppressWarnings("unchecked")
public CachedPersistentHashMap(File root, ObjectSerializer serializer) {
super(root, serializer, false);

cache = new HashMap<K, V>();

Iterator<Map.Entry<K, V>> iterator = new EntryIterator(this);
Iterator<Map.Entry<K, V>> iterator = new EntryIterator<K, V>(this);
while (iterator.hasNext()) {
Map.Entry<K, V> e = iterator.next();
cache.put(e.getKey(), e.getValue());
}
}

@Override
public synchronized boolean containsKey(Object key) {
return cache.containsKey(key);
}

@Override
public synchronized boolean containsValue(Object v) {
return cache.containsValue(v);
}

@Override
@SuppressWarnings("unchecked")
public synchronized V get(Object key) {
if (cache.containsKey(key))
Expand All @@ -58,26 +60,31 @@ public synchronized V get(Object key) {
return value;
}

@Override
public synchronized V put(K key, V value) {
cache.put(key, value);

return super.put(key, value);
}

@Override
public synchronized V remove(Object key) {
cache.remove(key);

return super.remove(key);
}

@Override
public boolean isEmpty() {
return cache.isEmpty();
}

@Override
public int size() {
return cache.size();
}

@Override
public synchronized void clear() {
cache.clear();
super.clear();
Expand Down

0 comments on commit 1b31016

Please sign in to comment.