summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-25 07:13:27 (EDT)
committerEike Stepper2007-08-25 07:13:27 (EDT)
commite60607f76ca99bcea2f2c7b0f5152de334f5b2ea (patch)
tree6987268b0d6fecf82b23eb1116aafe572f98fc24
parentd9ad9a14370999ba7aa654773360862a63240347 (diff)
downloadcdo-e60607f76ca99bcea2f2c7b0f5152de334f5b2ea.zip
cdo-e60607f76ca99bcea2f2c7b0f5152de334f5b2ea.tar.gz
cdo-e60607f76ca99bcea2f2c7b0f5152de334f5b2ea.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SortedFileMapTest.java5
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/SortedFileMap.java7
2 files changed, 9 insertions, 3 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SortedFileMapTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SortedFileMapTest.java
index afafc19..65fbd54 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SortedFileMapTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/SortedFileMapTest.java
@@ -27,6 +27,11 @@ public class SortedFileMapTest extends AbstractOMTest
public void testMap() throws Exception
{
File file = new File("testMap.dat");
+ if (file.exists())
+ {
+ file.delete();
+ }
+
SortedFileMap<Integer, String> map = null;
try
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/SortedFileMap.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/SortedFileMap.java
index 13dc5eb..244ec56 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/SortedFileMap.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/SortedFileMap.java
@@ -101,9 +101,9 @@ public abstract class SortedFileMap<K extends Comparable, V> implements Closeabl
try
{
long index = search(key);
- long pos = randomAccessFile.getFilePointer();
if (index >= 0)
{
+ long pos = randomAccessFile.getFilePointer();
V oldValue = readValue(randomAccessFile);
randomAccessFile.seek(pos);
writeValue(randomAccessFile, value);
@@ -111,7 +111,7 @@ public abstract class SortedFileMap<K extends Comparable, V> implements Closeabl
}
index = -index - 1;
- for (long i = entryCount; i >= index; --i)
+ for (long i = entryCount; i > index; --i)
{
randomAccessFile.seek((i - 1) * entrySize);
K k = readKey(randomAccessFile);
@@ -122,7 +122,8 @@ public abstract class SortedFileMap<K extends Comparable, V> implements Closeabl
writeValue(randomAccessFile, v);
}
- randomAccessFile.seek(pos);
+ ++entryCount;
+ randomAccessFile.seek(getPosition(index));
writeKey(randomAccessFile, key);
writeValue(randomAccessFile, value);
return null;