Skip to content

Commit

Permalink
Upgraded HPPC to version 0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mcelvg committed Jul 14, 2015
1 parent cfe981e commit 337403c
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 193 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<dependency>
<groupId>com.carrotsearch</groupId>
<artifactId>hppc</artifactId>
<version>0.6.1</version>
<version>0.7.1</version>
</dependency>
<dependency>
<groupId>org.tukaani</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;

import com.carrotsearch.hppc.CharCharOpenHashMap;
import com.carrotsearch.hppc.cursors.CharCharCursor;

import edu.emory.clir.clearnlp.collection.pair.CharCharPair;

Expand All @@ -35,23 +36,23 @@ public class CharCharHashMap implements Serializable, Iterable<CharCharPair>
{
private static final long serialVersionUID = -1072021691426162355L;
static public char DEFAULT_VALUE = '\u0000';
private CharCharOpenHashMap g_map;
private com.carrotsearch.hppc.CharCharHashMap g_map;

public CharCharHashMap()
{
g_map = new CharCharOpenHashMap();
g_map = new com.carrotsearch.hppc.CharCharHashMap();
}

public CharCharHashMap(int initialCapacity)
{
g_map = new CharCharOpenHashMap(initialCapacity);
g_map = new com.carrotsearch.hppc.CharCharHashMap(initialCapacity);
}

@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
List<CharCharPair> list = (List<CharCharPair>)in.readObject();
g_map = new CharCharOpenHashMap(list.size());
g_map = new com.carrotsearch.hppc.CharCharHashMap(list.size());
putAll(list);
}

Expand Down Expand Up @@ -119,32 +120,27 @@ public Iterator<CharCharPair> iterator()
{
Iterator<CharCharPair> it = new Iterator<CharCharPair>()
{
private final int key_size = g_map.keys.length;
private int current_index = 0;
private final Iterator<CharCharCursor> g_iter = g_map.iterator();

@Override
public boolean hasNext()
{
for (; current_index < key_size; current_index++)
{
if (g_map.allocated[current_index])
return true;
}

return false;
return g_iter.hasNext();
}

@Override
public CharCharPair next()
{
if (current_index < key_size)
CharCharPair p = null;
try{
CharCharCursor cursor = g_iter.next();
p = new CharCharPair(cursor.key, cursor.value);
}
catch (NoSuchElementException e)
{
CharCharPair p = new CharCharPair(g_map.keys[current_index], g_map.values[current_index]);
current_index++;
return p;

}

return null;
return p;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 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
* 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,
Expand All @@ -22,8 +22,9 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;

import com.carrotsearch.hppc.CharIntOpenHashMap;
import com.carrotsearch.hppc.cursors.CharIntCursor;

import edu.emory.clir.clearnlp.collection.pair.CharIntPair;

Expand All @@ -35,23 +36,23 @@ public class CharIntHashMap implements Serializable, Iterable<CharIntPair>
{
private static final long serialVersionUID = -1072021691426162355L;
static public char DEFAULT_VALUE = '\u0000';
private CharIntOpenHashMap g_map;
private com.carrotsearch.hppc.CharIntHashMap g_map;

public CharIntHashMap()
{
g_map = new CharIntOpenHashMap();
g_map = new com.carrotsearch.hppc.CharIntHashMap();
}

public CharIntHashMap(int initialCapacity)
{
g_map = new CharIntOpenHashMap(initialCapacity);
g_map = new com.carrotsearch.hppc.CharIntHashMap(initialCapacity);
}

@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
List<CharIntPair> list = (List<CharIntPair>)in.readObject();
g_map = new CharIntOpenHashMap(list.size());
g_map = new com.carrotsearch.hppc.CharIntHashMap(list.size());
putAll(list);
}

Expand Down Expand Up @@ -119,32 +120,27 @@ public Iterator<CharIntPair> iterator()
{
Iterator<CharIntPair> it = new Iterator<CharIntPair>()
{
private final int key_size = g_map.keys.length;
private int current_index = 0;
private final Iterator<CharIntCursor> g_iter = g_map.iterator();

@Override
public boolean hasNext()
{
for (; current_index < key_size; current_index++)
{
if (g_map.allocated[current_index])
return true;
}

return false;
return g_iter.hasNext();
}

@Override
public CharIntPair next()
{
if (current_index < key_size)
CharIntPair p = null;
try{
CharIntCursor cursor = g_iter.next();
p = new CharIntPair(cursor.key, cursor.value);
}
catch (NoSuchElementException e)
{
CharIntPair p = new CharIntPair(g_map.keys[current_index], g_map.values[current_index]);
current_index++;
return p;

}

return null;
return p;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 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
* 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,
Expand All @@ -22,8 +22,9 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;

import com.carrotsearch.hppc.CharObjectOpenHashMap;
import com.carrotsearch.hppc.cursors.CharObjectCursor;

import edu.emory.clir.clearnlp.collection.pair.ObjectCharPair;

Expand All @@ -34,23 +35,23 @@
public class CharObjectHashMap<T> implements Serializable, Iterable<ObjectCharPair<T>>
{
private static final long serialVersionUID = -1072021691426162355L;
private CharObjectOpenHashMap<T> g_map;
private com.carrotsearch.hppc.CharObjectHashMap<T> g_map;

public CharObjectHashMap()
{
g_map = new CharObjectOpenHashMap<T>();
g_map = new com.carrotsearch.hppc.CharObjectHashMap<T>();
}

public CharObjectHashMap(int initialCapacity)
{
g_map = new CharObjectOpenHashMap<T>(initialCapacity);
g_map = new com.carrotsearch.hppc.CharObjectHashMap<T>(initialCapacity);
}

@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
List<ObjectCharPair<T>> list = (List<ObjectCharPair<T>>)in.readObject();
g_map = new CharObjectOpenHashMap<T>(list.size());
g_map = new com.carrotsearch.hppc.CharObjectHashMap<T>(list.size());
putAll(list);
}

Expand Down Expand Up @@ -124,32 +125,27 @@ public Iterator<ObjectCharPair<T>> iterator()
{
Iterator<ObjectCharPair<T>> it = new Iterator<ObjectCharPair<T>>()
{
private final int key_size = g_map.keys.length;
private int current_index = 0;
private final Iterator<CharObjectCursor<T>> g_iter = g_map.iterator();

@Override
public boolean hasNext()
{
for (; current_index < key_size; current_index++)
{
if (g_map.allocated[current_index])
return true;
}

return false;
return g_iter.hasNext();
}

@Override
public ObjectCharPair<T> next()
{
if (current_index < key_size)
ObjectCharPair<T> p = null;
try{
CharObjectCursor<T> cursor = g_iter.next();
p = new ObjectCharPair<T>(cursor.value, cursor.key);
}
catch (NoSuchElementException e)
{
ObjectCharPair<T> p = new ObjectCharPair<T>(g_map.values[current_index], g_map.keys[current_index]);
current_index++;
return p;

}

return null;
return p;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 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
* 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,
Expand All @@ -22,8 +22,9 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;

import com.carrotsearch.hppc.IntDoubleOpenHashMap;
import com.carrotsearch.hppc.cursors.IntDoubleCursor;

import edu.emory.clir.clearnlp.collection.pair.DoubleIntPair;

Expand All @@ -34,23 +35,23 @@
public class IntDoubleHashMap implements Serializable, Iterable<DoubleIntPair>
{
private static final long serialVersionUID = 5327212904932776361L;
private IntDoubleOpenHashMap g_map;
private com.carrotsearch.hppc.IntDoubleHashMap g_map;

public IntDoubleHashMap()
{
g_map = new IntDoubleOpenHashMap();
g_map = new com.carrotsearch.hppc.IntDoubleHashMap();
}

public IntDoubleHashMap(int initialCapacity)
{
g_map = new IntDoubleOpenHashMap(initialCapacity);
g_map = new com.carrotsearch.hppc.IntDoubleHashMap(initialCapacity);
}

@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
List<DoubleIntPair> list = (List<DoubleIntPair>)in.readObject();
g_map = new IntDoubleOpenHashMap(list.size());
g_map = new com.carrotsearch.hppc.IntDoubleHashMap(list.size());
putAll(list);
}

Expand Down Expand Up @@ -118,32 +119,27 @@ public Iterator<DoubleIntPair> iterator()
{
Iterator<DoubleIntPair> it = new Iterator<DoubleIntPair>()
{
private final int key_size = g_map.keys.length;
private int current_index = 0;
private final Iterator<IntDoubleCursor> g_iter = g_map.iterator();

@Override
public boolean hasNext()
{
for (; current_index < key_size; current_index++)
{
if (g_map.allocated[current_index])
return true;
}

return false;
return g_iter.hasNext();
}

@Override
public DoubleIntPair next()
{
if (current_index < key_size)
DoubleIntPair p = null;
try{
IntDoubleCursor cursor = g_iter.next();
p = new DoubleIntPair(cursor.value, cursor.key);
}
catch (NoSuchElementException e)
{
DoubleIntPair p = new DoubleIntPair(g_map.values[current_index], g_map.keys[current_index]);
current_index++;
return p;

}

return null;
return p;
}

@Override
Expand Down
Loading

0 comments on commit 337403c

Please sign in to comment.