TODO: Optimize performance (maybe use a map)
505361
public T getValueByString(String key) {
        for (T value : values) {
            if (keyFactory.generateKey(value).equals(key)) {
                return value;
            }
        }
        return null;
    }
210523
public AndCondition optimize() {
        AndCondition result = new AndCondition();
        for (Condition each : conditions) {
            if (Condition.class.equals(each.getClass())) {
                result.getConditions().add(each);
            }
        }
        if (result.getConditions().isEmpty()) {
            result.getConditions().add(new NullCondition());
        }
        return result;
    }
655670
public Map<GraphObject, Integer> run()
	{
		initMaps();

		// Add all source nodes to the queue if traversal is needed

		if (limit > 0)
		{
			queue.addAll(sourceSet);
		}

		// Initialize dist and color of source set

		for (Node source : sourceSet)
		{
			setLabel(source, 0);
			setColor(source, GRAY);

			labelEquivRecursive(source, UPWARD, 0, true, false);
			labelEquivRecursive(source, DOWNWARD, 0, true, false);
		}

		// Process the queue

		while (!queue.isEmpty())
		{
			Node current = queue.remove(0);

			processNode(current);

			// Current node is processed
			setColor(current, BLACK);
		}

		return dist;
	}
92752
public static void main( String args[] ) {
		BenchmarkNearestNeighborCorrect app = new BenchmarkNearestNeighborCorrect();

//		app.evaluateDataSet(3,30);
//		app.evaluateDataSet(3,300);
//		app.evaluateDataSet(3,600);
//		app.evaluateDataSet(5,10000);
		app.evaluateDataSet(10,100000,1000);
		app.evaluateDataSet(20,100000,1000);
		app.evaluateDataSet(60,100000,1000);
		app.evaluateDataSet(120,100000,1000);

		try {
			synchronized ( app ) {
				Thread.sleep(100);
			}
		} catch (InterruptedException e) {}
	}
870434
def map_return(self):
        """"""
        with Pool(self.cpu_count) as pool:
            vals = pool.map(self._func, self._iterable)
            pool.close()
            return vals
825180
function map(array, fn) {
	const result = [];
	let length = array.length;
	while (length--) {
		result[length] = fn(array[length]);
	}
	return result;
}
1085271
function map (f, arr) {
    var result = [], i, n;
    for (i = 0, n = arr.length; i < n; i++) {
      result.push(f(arr[i]));
    }
    return result;
  }
1058597
function () {
        while (this.head !== null) {
            var temp = this.head;
            this.head = this.head.next();   // use next() the instead of "_next", otherwise it will loop forever
            temp._list = null;
            temp._next = null;
            temp._prev = null;
        }

        this.head = null;
        this.size = 0;
    }
831140
function() {
                var mapping = this._getResourceColorIndexMapping();
                var used = [],
                    resource;

                for (resource in mapping) {
                    if (Object.prototype.hasOwnProperty.call(mapping, resource)) {
                        used.push(resource);
                    }
                }

                return used;
            }
1315550
def map(self, func, iterable, chunksize=None):
        
        # The key magic is that we must call r.get() with a timeout, because a
        # Condition.wait() without a timeout swallows KeyboardInterrupts.
        r = self.map_async(func, iterable, chunksize)

        while True:
            try:
                return r.get(self.wait_timeout)
            except TimeoutError:
                pass
            except KeyboardInterrupt:
                self.terminate()
                self.join()
                raise
348280
function map(arr, iter) {
    if (Immutable.Map.isMap(arr)) {
        var type = 'Map';
        if (Immutable.OrderedMap.isOrderedMap(arr)) {
            type = 'OrderedMap';
        }

        return mapAsList(arr, function(value, key) {
            return Q(iter(value, key))
            .then(function(result) {
                return [key, result];
            });
        })
        .then(function(result) {
            return Immutable[type](result);
        });
    } else {
        return mapAsList(arr, iter)
        .then(function(result) {
            return Immutable.List(result);
        });
    }
}
666853
public final Map<Tuple2<String, UUID>, Tuple2<Long, Long>> getWaitTimeouts() {
        return unmodifiableMap(waitTimeouts);
    }
1079254
function mapCOW(arr, func) {
    var res = null;

    for(var i=0; i<arr.length; i++) {
        var item = func(arr[i]);

        if(item !== arr[i]) {
            if(!res) {
                res = arr.slice();
            }

            res[i] = item;
        }
    }

    return res || arr;
}
170316
public void optimize() throws CorruptIndexException, IOException
   {
      for (PersistentIndex index : indexes)
      {
         IndexWriter writer = index.getIndexWriter();
         writer.forceMerge(1, true);
      }
   }
983892
private Map<Integer, List<Row>> createTimeEntryMap(List<Row> rows) throws ParseException
   {
      Map<Integer, List<Row>> map = new HashMap<Integer, List<Row>>();
      for (Row row : rows)
      {
         Integer workPatternID = row.getInteger("ID");
         String shifts = row.getString("SHIFTS");
         map.put(workPatternID, createTimeEntryRowList(shifts));
      }
      return map;
   }
99217
@Override protected void writeMap(AutoBuffer ab, int mode) {

    // For faster K/V store walking get the NBHM raw backing array,
    // and walk it directly.
    Object[] kvs = _map.raw_array();

    // Start the walk at slot 2, because slots 0,1 hold meta-data
    // In the raw backing array, Keys and Values alternate in slots
    // Ignore tombstones and Primes and null's
    switch( mode ) {
    case 1:  // <String,String>
      for( int i=2; i<kvs.length; i += 2 )
        if( kvs[i] instanceof String && kvs[i+1] instanceof String )
          ab.putStr((String)kvs[i]).putStr((String)kvs[i+1]);
      break;
    case 2: // <String,Freezable>
      for( int i=2; i<kvs.length; i += 2 )
        if( kvs[i] instanceof String && kvs[i+1] instanceof Iced   )
          ab.putStr((String)kvs[i]).put   ((Freezable)kvs[i+1]);
      break;
    case 3: // <Freezable,String>
      for( int i=2; i<kvs.length; i += 2 )
        if( kvs[i] instanceof Iced   && kvs[i+1] instanceof String )
          ab.put   ((Freezable  )kvs[i]).putStr((String)kvs[i+1]);
      break;
    case 4: // <Freezable,Freezable>
      for( int i=2; i<kvs.length; i += 2 )
        if( kvs[i] instanceof Freezable   && kvs[i+1] instanceof Freezable   )
          ab.put   ((Freezable  )kvs[i]).put   ((Freezable  )kvs[i+1]);
      break;
    case 5:  // <String,Freezable[]>
      for( int i=2;i<kvs.length; i+=2 )
        if( kvs[i] instanceof String && kvs[i+1] instanceof Freezable[] ) {
          Freezable[] vals = (Freezable[])kvs[i+1];
          ab.putStr((String)kvs[i]).put4(vals.length);  // key len vals
          for(Freezable v: vals) ab.put(v);
        }
      break;
    case 6: // <Freezable,Freezable[]>
      for( int i=2;i<kvs.length; i+=2 )
        if( kvs[i] instanceof Freezable && kvs[i+1] instanceof Freezable[] ) {
          Freezable[] vals = (Freezable[])kvs[i+1];
          ab.put((Freezable)kvs[i]).put4(vals.length);  // key len vals
          for(Freezable v: vals) ab.put(v);
        }
      break;
    default: throw H2O.fail();
    }
  }
149723
Map<String, Object> consume() {
    Container values = stack.getLast();
    stack.clear();

    return ((Container.Table) values).consume();
  }