本文整理汇总了Java中gnu.trove.iterator.TObjectDoubleIterator类的典型用法代码示例。如果您正苦于以下问题:Java TObjectDoubleIterator类的具体用法?Java TObjectDoubleIterator怎么用?Java TObjectDoubleIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TObjectDoubleIterator类属于gnu.trove.iterator包,在下文中一共展示了TObjectDoubleIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: iterator
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
@Override
public Iterator<Pair<KeyArgs, Double>> iterator() {
return new Iterator<Pair<KeyArgs, Double>>() {
private final TObjectDoubleIterator<KeyArgs> innerIterator = values.iterator();
@Override
public boolean hasNext() {
return innerIterator.hasNext();
}
@Override
public Pair<KeyArgs, Double> next() {
if (innerIterator.hasNext()) {
innerIterator.advance();
return Pair.of(innerIterator.key(), innerIterator.value());
} else {
return null;
}
}
@Override
public void remove() {
innerIterator.remove();
}
};
}
示例2: iterator
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
@Override
public Iterator<ObjectDoubleEntry<KEY>> iterator() {
return new Iterator<ObjectDoubleEntry<KEY>>() {
TObjectDoubleIterator<KEY> iter = paramsMap.iterator();
ObjectDoubleEntry<KEY> entry = new ObjectDoubleEntry<KEY>();
@Override
public boolean hasNext() {
return iter.hasNext();
}
@Override
public ObjectDoubleEntry<KEY> next() {
iter.advance();
entry.key = iter.key();
entry.value = iter.value();
return entry;
}
@Override
public void remove() {
throw new UnsupportedOperationException("Not supported");
}
};
}
示例3: dot
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
/**
* compute the inner product between this and vec.
*/
public double dot(StringKeyedVector vec) {
if (vec instanceof LazyVector) {
return vec.dot(this);
}
ByteArrayDoubleHashMap vec_small = this.size() > vec.size() ? vec.vector
: this.vector;
ByteArrayDoubleHashMap vec_big = this.size() > vec.size() ? this.vector
: vec.vector;
double res = 0.0;
for (TObjectDoubleIterator<byte[]> it = vec_small.troveIterator(); it
.hasNext();) {
it.advance();
if (vec_big.containsKey(it.key())) {
res += it.value() * vec_big.getPrimitive(it.key());
}
}
return res;
}
示例4: iterator
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
public Iterator<Map.Entry<String, Double>> iterator() {
return new Iterator<Map.Entry<String, Double>>() {
private TObjectDoubleIterator<byte[]> iter = troveIterator();
public boolean hasNext() {
return iter.hasNext();
}
public void remove() {
iter.remove();
}
public Map.Entry<String, Double> next() {
iter.advance();
return new AbstractMap.SimpleImmutableEntry<String, Double>(
byteArrayToString(iter.key()), iter.value());
}
};
}
示例5: equals
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
/**
* 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 TObjectDoubleMap ) ) {
return false;
}
TObjectDoubleMap that = ( TObjectDoubleMap ) other;
if ( that.size() != this.size() ) {
return false;
}
try {
TObjectDoubleIterator iter = this.iterator();
while ( iter.hasNext() ) {
iter.advance();
Object key = iter.key();
double value = iter.value();
if ( value == no_entry_value ) {
if ( !( that.get( key ) == that.getNoEntryValue() &&
that.containsKey( key ) ) ) {
return false;
}
} else {
if ( value != that.get( key ) ) {
return false;
}
}
}
} catch ( ClassCastException ex ) {
// unused.
}
return true;
}
示例6: equals
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
/**
* 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(final Object other ) {
if ( ! ( other instanceof TObjectDoubleMap ) ) {
return false;
}
final TObjectDoubleMap that = ( TObjectDoubleMap ) other;
if ( that.size() != this.size() ) {
return false;
}
try {
final TObjectDoubleIterator iter = this.iterator();
while ( iter.hasNext() ) {
iter.advance();
final Object key = iter.key();
final double value = iter.value();
if ( value == no_entry_value ) {
if ( !( that.get( key ) == that.getNoEntryValue() &&
that.containsKey( key ) ) ) {
return false;
}
} else {
if ( value != that.get( key ) ) {
return false;
}
}
}
} catch ( final ClassCastException ex ) {
// unused.
}
return true;
}
示例7: equals
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
/**
* 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
@SuppressWarnings("rawtypes")
public boolean equals( Object other ) {
if ( ! ( other instanceof TObjectDoubleMap ) ) {
return false;
}
TObjectDoubleMap that = ( TObjectDoubleMap ) other;
if ( that.size() != this.size() ) {
return false;
}
try {
TObjectDoubleIterator iter = this.iterator();
while ( iter.hasNext() ) {
iter.advance();
Object key = iter.key();
double value = iter.value();
if ( value == no_entry_value ) {
if ( !( that.get( key ) == that.getNoEntryValue() &&
that.containsKey( key ) ) ) {
return false;
}
} else {
if ( value != that.get( key ) ) {
return false;
}
}
}
} catch ( ClassCastException ex ) {
// unused.
}
return true;
}
示例8: equals
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
/**
* 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 TObjectDoubleMap ) ) {
return false;
}
TObjectDoubleMap that = ( TObjectDoubleMap ) other;
if ( that.size() != this.size() ) {
return false;
}
try {
TObjectDoubleIterator iter = this.iterator();
while ( iter.hasNext() ) {
iter.advance();
Object key = iter.key();
double value = iter.value();
if ( value == no_entry_value ) {
if ( !( that.get( key ) == that.getNoEntryValue() && that.containsKey( key ) ) ) {
return false;
}
} else {
if ( value != that.get( key ) ) {
return false;
}
}
}
} catch ( ClassCastException ex ) {
// unused.
}
return true;
}
示例9: equals
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
/**
* 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 TObjectDoubleMap ) ) {
return false;
}
TObjectDoubleMap that = ( TObjectDoubleMap ) other;
if ( that.size() != this.size() ) {
return false;
}
try {
TObjectDoubleIterator iter = this.iterator();
while ( iter.hasNext() ) {
iter.advance();
Object key = iter.key();
double value = iter.value();
if ( value == no_entry_value ) {
if ( !( that.get( key ) == that.getNoEntryValue() && that.containsKey( key ) ) ) {
return false;
}
} else {
if ( value != that.get( key ) ) {
return false;
}
}
}
} catch ( ClassCastException ex ) {
// unused.
logger.warn("An error occurred!", ex);
}
return true;
}
示例10: delazify
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
public void delazify() {
for (TObjectDoubleIterator<byte[]> it = vector.troveIterator(); it
.hasNext();) {
it.advance();
long startIter = (long)iterations.getPrimitive(it.key()); // defaults
// to 0.0
if (startIter < iteration) {
it.setValue(updater.lazyUpdate(it.key().toString(), it.value(), startIter, iteration));
iterations.putPrimitive(it.key(), (double)iteration);
}
}
removeZeroCoordinates();
}
示例11: skipToIteration
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
public void skipToIteration(long iter) {
delazify();
iteration = iter;
for (TObjectDoubleIterator<byte[]> it = iterations.troveIterator(); it
.hasNext();) {
it.advance();
it.setValue((double)iter);
}
}
示例12: removeZeroCoordinates
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
/**
* Remove zeros that may have appeared as a result of a transform
*/
public void removeZeroCoordinates() {
for (TObjectDoubleIterator<byte[]> it = vector.troveIterator(); it
.hasNext();) {
it.advance();
if (Utilities.floatingPointEquals(it.value(), 0d)) {
iterations.removePrimitive(it.key());
it.remove();
}
}
}
示例13: dotWithSKV
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
protected double dotWithSKV(StringKeyedVector vec) {
// dont figure out which ones bigger etc, since delazifying this to get
// the size is too slow.
double res = 0.0;
for (TObjectDoubleIterator<byte[]> it = vec.vector.troveIterator(); it
.hasNext();) {
it.advance();
res += it.value() * delazifyCoordinate(it.key());
}
return res;
}
示例14: addScaled
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
/**
* add a multiple of vec to this.
*/
public void addScaled(StringKeyedVector vec, double scale) {
if (vec instanceof LazyVector) {
((LazyVector)vec).delazify();
}
for (TObjectDoubleIterator<byte[]> it = vec.vector.troveIterator(); it
.hasNext();) {
it.advance();
addToCoordinateInternal(it.key(), scale * it.value());
}
}
示例15: multiplyPointwise
import gnu.trove.iterator.TObjectDoubleIterator; //导入依赖的package包/类
public StringKeyedVector multiplyPointwise(StringKeyedVector vec) {
StringKeyedVector res = new StringKeyedVector();
if (vec instanceof LazyVector) {
((LazyVector)vec).delazify();
}
for (TObjectDoubleIterator<byte[]> it = vec.vector.troveIterator(); it
.hasNext();) {
it.advance();
res.vector.putPrimitive(it.key(), vector.getPrimitive(it.key())
* it.value());
}
return res;
}