Java Code Examples for it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry#getValue()

The following examples show how to use it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
public void addQuantity(WorldObject worldObject, int quantity) {
	String name = worldObject.getProperty(Constants.NAME);
	boolean found = false;
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject object = entry.getValue();
		if (object.getProperty(Constants.NAME).equals(name)) {
			object.setProperty(Constants.QUANTITY, object.getProperty(Constants.QUANTITY) + quantity);
			found = true;
			return;
		}
	}
	
	if (!found) {
		worldObject.setProperty(Constants.QUANTITY, quantity);
		add(worldObject);
	}
}
 
Example 2
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public<T> List<WorldObject> getWorldObjects(ManagedProperty<T> propertyKey, T value) {
	List<WorldObject> result = new ArrayList<>();
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject worldObject = entry.getValue();
		if (worldObject.hasProperty(propertyKey)) {
			if (worldObject.getProperty(propertyKey) == value) {
				result.add(worldObject);
			}
		}
	}
	return result;
}
 
Example 3
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public int getIndexFor(StringProperty property, String value, Function<WorldObject, Boolean> testFunction) {
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject worldObject = entry.getValue();
		if (worldObject.hasProperty(property) && worldObject.getProperty(property).equals(value)) {
			if (testFunction.apply(worldObject)) {
				return entry.getIntKey();
			}
		}
	}
	return -1;
}
 
Example 4
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public WorldObjectContainer copy() {
	WorldObjectContainer result = new WorldObjectContainer();
	result.currentIndex = currentIndex;
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject worldObject = entry.getValue();
		result.worldObjects.put(entry.getIntKey(), worldObject.deepCopy());
	}
	return result;
}
 
Example 5
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public<T> void removeAllQuantity(ManagedProperty<T> propertyKey) {
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject worldObject = entry.getValue();
		if (worldObject.hasProperty(propertyKey)) {
			worldObjects.remove(entry.getIntKey());
			return;
		}
	}
}
 
Example 6
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public<T> int getIndexFor(ManagedProperty<T> propertyKey, T value, Function<WorldObject, Boolean> testFunction) {
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject worldObject = entry.getValue();
		if (worldObject.hasProperty(propertyKey) && (worldObject.getProperty(propertyKey) == value) && testFunction.apply(worldObject)) {
			return entry.getIntKey();
		}
	}
	return -1;
}
 
Example 7
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public<T> int getIndexFor(ManagedProperty<T> propertyKey, T value) {
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject worldObject = entry.getValue();
		if (worldObject.hasProperty(propertyKey) && worldObject.getProperty(propertyKey) == value) {
			return entry.getIntKey();
		}
	}
	return -1;
}
 
Example 8
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public<T> int getIndexFor(ManagedProperty<T> propertyKey, Function<WorldObject, Boolean> testFunction) {
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject worldObject = entry.getValue();
		if (worldObject.hasProperty(propertyKey) && testFunction.apply(worldObject)) {
			return entry.getIntKey();
		}
	}
	return -1;
}
 
Example 9
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public<T> int getIndexFor(ManagedProperty<T> propertyKey) {
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject worldObject = entry.getValue();
		if (worldObject.hasProperty(propertyKey)) {
			return entry.getIntKey();
		}
	}
	return -1;
}
 
Example 10
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public<T> int getIndexFor(Function<WorldObject, Boolean> testFunction) {
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject worldObject = entry.getValue();
		if (testFunction.apply(worldObject)) {
			return entry.getIntKey();
		}
	}
	return -1;
}
 
Example 11
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public List<WorldObject> getWorldObjectsByFunction(ManagedProperty<?> propertyKey, Function<WorldObject, Boolean> testFunction) {
	List<WorldObject> result = new ArrayList<>();
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject worldObject = entry.getValue();
		if (worldObject.hasProperty(propertyKey)) {
			if (testFunction.apply(worldObject)) {
				result.add(worldObject);
			}
		}
	}
	return result;
}
 
Example 12
Source File: ArrayDictionaryRecords.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
@Override
public DictionaryRecords build() {
	int size = records.size();
	int[][] array = new int[size][];
	for (Entry<int[]> entry : records.int2ObjectEntrySet()) {
		int id = entry.getIntKey();
		array[id] = entry.getValue();
	}
	return new ArrayDictionaryRecords(array);
}
 
Example 13
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public int getIndexFor(WorldObject worldObjectToFind) {
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject worldObject = entry.getValue();
		if (worldObject == worldObjectToFind) {
			return entry.getIntKey();
		}
	}
	return -1;
}
 
Example 14
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public<T> int getQuantityFor(ManagedProperty<T> propertyKey) {
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject worldObject = entry.getValue();
		if (worldObject.hasProperty(propertyKey)) {
			return worldObject.getProperty(Constants.QUANTITY);
		}
	}
	return 0;
}
 
Example 15
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
public void moveItemsFrom(WorldObjectContainer otherInventory) {
	ObjectIterator<Entry<WorldObject>> iterator = otherInventory.worldObjects.int2ObjectEntrySet().fastIterator();
	while(iterator.hasNext()) {
		Entry<WorldObject> otherEntry = iterator.next();
		WorldObject otherWorldObject = otherEntry.getValue();
	
		if (otherWorldObject.getProperty(Constants.QUANTITY) == null) {
			throw new IllegalStateException("otherWorldObject.getProperty(Constants.QUANTITY) is null: " + otherWorldObject);
		}
		addQuantity(otherWorldObject, otherWorldObject.getProperty(Constants.QUANTITY));
		iterator.remove();
	}
}
 
Example 16
Source File: Int2Double2ObjectSortedArrayTableTest.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static <T> Double2ObjectSortedMap<T>[] toArray(
	Int2ObjectMap<Double2ObjectSortedMap<T>> map, int size) {
	Double2ObjectSortedMap<T>[] array = new Double2ObjectSortedMap[size];
	for (Entry<Double2ObjectSortedMap<T>> entry : map.int2ObjectEntrySet()) {
		int columnKey = entry.getIntKey();
		array[columnKey] = entry.getValue();
	}
	return array;
}
 
Example 17
Source File: GroupingRhsValidationTask.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private double calculateMinSimilarity(Iterable<Entry<Collection<int[]>>> map) {
	Iterator<Entry<Collection<int[]>>> it = map.iterator();
	//does order have an impact on runtime?
	while (it.hasNext() && shouldUpdate(minSimilarity)) {
		Entry<Collection<int[]>> entry = it.next();
		int rightValue = entry.getIntKey();
		Collection<int[]> records = entry.getValue();
		updateMinSimilarity(rightValue, records);
	}
	return minSimilarity;
}
 
Example 18
Source File: AbstractRhsValidationTask.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
@Override
public void validate(Iterable<int[]> leftMatches, IntIterable right) {
	Int2ObjectMultimap<int[]> grouped = groupByValue(leftMatches);
	Iterator<Entry<Collection<int[]>>> it = grouped.iterator();
	while (it.hasNext() && shouldUpdate()) {
		Entry<Collection<int[]>> entry = it.next();
		int value = entry.getIntKey();
		Collection<int[]> records = entry.getValue();
		threshold = updateThreshold(value, records, right);
	}
}
 
Example 19
Source File: WorldObjectContainer.java    From WorldGrower with GNU General Public License v3.0 4 votes vote down vote up
public void iterate(ObjIntConsumer<WorldObject> consumer) {
	for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) {
		WorldObject object = entry.getValue();
		consumer.accept(object, entry.getIntKey());
	}
}
 
Example 20
Source File: MapPositionListIndex.java    From metanome-algorithms with Apache License 2.0 4 votes vote down vote up
private static Cluster toCluster(Entry<IntSet> e) {
	return new Cluster(e.getIntKey(), e.getValue());
}