Permalink
Browse files

Merge pull request #5 from mcelvg/master

Upgraded HPPC to version 0.7.1
  • Loading branch information...
jdchoi77 committed Jul 13, 2016
2 parents b039300 + c6494e4 commit 9edb7ab90e7a7d296d512e374f644a2374c65822
View
@@ -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>
@@ -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;
@@ -35,23 +36,23 @@
{
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);
}
@@ -119,32 +120,27 @@ public String toString()
{
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
@@ -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,
@@ -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;
@@ -35,23 +36,23 @@
{
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);
}
@@ -119,32 +120,27 @@ public String toString()
{
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
@@ -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,
@@ -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;
@@ -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);
}
@@ -124,32 +125,27 @@ public String toString()
{
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
@@ -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,
@@ -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;
@@ -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);
}
@@ -118,32 +119,27 @@ public String toString()
{
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
Oops, something went wrong.

0 comments on commit 9edb7ab

Please sign in to comment.