@Test public void testArgMax() { ArgMax<Integer, Double> argmax = new ArgMax<>(-1, Double.NEGATIVE_INFINITY); double[] r = {-1, -30, -4, 1, -4, 94, 19, 1, 10, -19}; for (int i = 0; i < r.length; i++) { argmax.update(i, r[i]); } assertEquals(5, argmax.getArgmax().intValue()); assertEquals(94d, argmax.getMaxValue(), 0.0); }
public ArgMax(Map< T, V > values) { Iterator<Map.Entry<T, V>> valIterator = values.entrySet().iterator(); if ( valIterator.hasNext() ) { Map.Entry<T, V> e = valIterator.next(); this.object = e.getKey(); this.value = e.getValue(); } while( valIterator.hasNext() ) { Map.Entry<T, V> e = valIterator.next(); update(e.getKey(), e.getValue()); } }
ArgMax { public ArgMax(Map< T, V > values) { Iterator<Map.Entry<T, V>> valIterator = values.entrySet().iterator(); if ( valIterator.hasNext() ) { Map.Entry<T, V> e = valIterator.next(); this.object = e.getKey(); this.value = e.getValue(); } while( valIterator.hasNext() ) { Map.Entry<T, V> e = valIterator.next(); update(e.getKey(), e.getValue()); } } }
ArgMax { public ArgMax(Map< T, V > values) { Iterator<Map.Entry<T, V>> valIterator = values.entrySet().iterator(); if ( valIterator.hasNext() ) { Map.Entry<T, V> e = valIterator.next(); this.object = e.getKey(); this.value = e.getValue(); } while( valIterator.hasNext() ) { Map.Entry<T, V> e = valIterator.next(); update(e.getKey(), e.getValue()); } } ArgMax(Map< T, V > values);  ArgMax(T initialObject, V initialValue);  ArgMax(T initialObject, V initialValue, boolean randomTieBreak); }
ArgMax { public ArgMax(Map< T, V > values) { Iterator<Map.Entry<T, V>> valIterator = values.entrySet().iterator(); if ( valIterator.hasNext() ) { Map.Entry<T, V> e = valIterator.next(); this.object = e.getKey(); this.value = e.getValue(); } while( valIterator.hasNext() ) { Map.Entry<T, V> e = valIterator.next(); update(e.getKey(), e.getValue()); } } ArgMax(Map< T, V > values);  ArgMax(T initialObject, V initialValue);  ArgMax(T initialObject, V initialValue, boolean randomTieBreak); void update(T object, V value); V getMaxValue(); T getArgmax(); @Override String toString(); }
ArgMax { public ArgMax(Map< T, V > values) { Iterator<Map.Entry<T, V>> valIterator = values.entrySet().iterator(); if ( valIterator.hasNext() ) { Map.Entry<T, V> e = valIterator.next(); this.object = e.getKey(); this.value = e.getValue(); } while( valIterator.hasNext() ) { Map.Entry<T, V> e = valIterator.next(); update(e.getKey(), e.getValue()); } } ArgMax(Map< T, V > values);  ArgMax(T initialObject, V initialValue);  ArgMax(T initialObject, V initialValue, boolean randomTieBreak); void update(T object, V value); V getMaxValue(); T getArgmax(); @Override String toString();  }