it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry Java Examples
The following examples show how to use
it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry.
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 |
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: Int2Double2ObjectSortedArrayTableTest.java From metanome-algorithms with Apache License 2.0 | 5 votes |
@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 #3
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 #4
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 #5
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 #6
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 #7
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
public int getQuantityFor(ManagedProperty<?> propertyKey1, ManagedProperty<?> propertyKey2, Function<WorldObject, Boolean> testFunction) { for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) { WorldObject worldObject = entry.getValue(); if (worldObject.hasProperty(propertyKey1) && worldObject.hasProperty(propertyKey2)) { if (testFunction.apply(worldObject)) { return worldObject.getProperty(Constants.QUANTITY); } } } return 0; }
Example #8
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 #9
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
public<T> void removeQuantity(ManagedProperty<T> propertyKey, int quantity) { for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) { WorldObject object = entry.getValue(); if (object.hasProperty(propertyKey)) { object.increment(Constants.QUANTITY, -quantity); if (object.getProperty(Constants.QUANTITY) == 0) { worldObjects.remove(entry.getIntKey()); } return; } } }
Example #10
Source File: SparseTable.java From jstarcraft-ai with Apache License 2.0 | 5 votes |
@Override public SparseTable<T> setValues(T value) { for (Int2ObjectMap.Entry<T> term : cells.int2ObjectEntrySet()) { term.setValue(value); } return this; }
Example #11
Source File: ListRank.java From JavaFM with Mozilla Public License 2.0 | 5 votes |
@Override public double error(FM fm, ListWiseFMData test) { return test.streamByGroup().map(Entry::getValue) .mapToDouble((List<? extends FMInstance> group) -> { double[] p = getP(group); double[] q = getQ(fm, group); return IntStream.range(0, group.size()) .mapToDouble(i -> -p[i] * log(q[i])) .sum(); }) .average().getAsDouble(); }
Example #12
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 #13
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 #14
Source File: Int2ObjectMultimapTest.java From metanome-algorithms with Apache License 2.0 | 5 votes |
private static Map<Integer, Collection<String>> asMap( Iterable<Entry<Collection<String>>> multimap) { Map<Integer, Collection<String>> map = new HashMap<>(); Iterator<Entry<Collection<String>>> it = multimap.iterator(); it.forEachRemaining(e -> map.put(e.getIntKey(), e.getValue())); return map; }
Example #15
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 #16
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 #17
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 #18
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 #19
Source File: MapPositionListIndex.java From metanome-algorithms with Apache License 2.0 | 5 votes |
@Override public Spliterator<Cluster> spliterator() { Set<Entry<IntSet>> entries = entries(); return entries.stream() .map(MapPositionListIndex::toCluster) .spliterator(); }
Example #20
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
public int getIndexFor(WorldObject worldObjectToFind) { for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) { WorldObject worldObject = entry.getValue(); if (worldObject == worldObjectToFind) { return entry.getIntKey(); } } return -1; }
Example #21
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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 #22
Source File: GroupingRhsValidationTask.java From metanome-algorithms with Apache License 2.0 | 5 votes |
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 #23
Source File: AbstractRhsValidationTask.java From metanome-algorithms with Apache License 2.0 | 5 votes |
@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 #24
Source File: ArrayDictionaryRecords.java From metanome-algorithms with Apache License 2.0 | 5 votes |
@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 #25
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
public int getUnmodifiedTotalWeight() { int totalWeight = 0; for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) { WorldObject worldObject = entry.getValue(); Integer weight = worldObject.getProperty(Constants.WEIGHT); if (weight != null) { int quantity = worldObject.getProperty(Constants.QUANTITY); totalWeight += (weight.intValue() * quantity); } } return totalWeight; }
Example #26
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 4 votes |
public void iterate(ObjIntConsumer<WorldObject> consumer) { for(Entry<WorldObject> entry : worldObjects.int2ObjectEntrySet()) { WorldObject object = entry.getValue(); consumer.accept(object, entry.getIntKey()); } }
Example #27
Source File: SimpleListWiseFMData.java From JavaFM with Mozilla Public License 2.0 | 4 votes |
@Override public Stream<Entry<List<? extends FMInstance>>> streamByGroup() { return groupList.stream() .map(i -> new AbstractInt2ObjectMap.BasicEntry<>(i, map.get(i))); }
Example #28
Source File: Int2ObjectHashMultimap.java From metanome-algorithms with Apache License 2.0 | 4 votes |
private Set<Entry<Collection<T>>> entries() { return map.int2ObjectEntrySet(); }
Example #29
Source File: Int2ObjectHashMultimap.java From metanome-algorithms with Apache License 2.0 | 4 votes |
@Override public Spliterator<Entry<Collection<T>>> spliterator() { Set<Entry<Collection<T>>> entries = entries(); return entries.spliterator(); }
Example #30
Source File: Int2ObjectHashMultimap.java From metanome-algorithms with Apache License 2.0 | 4 votes |
@Override public Iterator<Entry<Collection<T>>> iterator() { Set<Entry<Collection<T>>> entries = entries(); return entries.iterator(); }