TODO: Optimize performance (maybe use a map)
497241
public int getIndexByString(String key) {
        int index = -1;
        for (T value : values) {
            index++;
            if (keyFactory.generateKey(value).equals(key)) {
                return index;
            }
        }
        return index;
    }
786866
private static <K, V> List<KeyValue<K, List<V>>> multimapToList(
      Marshaller<K> keyMarshaller, ListMultimap<Bytes, V> in) {
    List<Bytes> keys = Ordering.natural().sortedCopy(in.keySet());
    ImmutableList.Builder<KeyValue<K, List<V>>> out = ImmutableList.builder();
    for (Bytes keyBytes : keys) {
      K key = keyMarshaller.fromBytes(ByteBuffer.wrap(keyBytes.bytes));
      out.add(KeyValue.of(key, in.get(keyBytes)));
    }
    return out.build();
  }
964787
private static int getMapCount(int srcCount, int numNodes) {
    int numMaps = (int)(srcCount / OP_PER_MAP);
    numMaps = Math.min(numMaps, numNodes * MAX_MAPS_PER_NODE);
    return Math.max(numMaps, 1);
  }
1197288
function createCacheMap() {

	if (typeof Map === 'function') {
		return new Map();
	}

	var keys = [];
	var values = [];

	function getIndex(key) {
		return keys.indexOf(key);
	}

	function get(key) {
		return values[getIndex(key)];
	}

	function has(key) {
		return getIndex(key) !== -1;
	}

	function set(key, value) {
		var index = getIndex(key);
		if (index === -1) {
			index = keys.push(key) - 1;
		}
		values[index] = value;
	}

	function deleteFunc(key) {
		var index = getIndex(key);
		if (index === -1) {
			return false;
		}
		delete keys[index];
		delete values[index];
		return true;
	}

	function forEach(callback) {
		keys.forEach(function(key, index) {
			if (key !== undefined) {
				callback(values[index], key);
			}
		});
	}

	return {
		set: set,
		get: get,
		has: has,
		delete: deleteFunc,
		forEach: forEach,
	};
}
547474
def map(self):
        """"""
        with Pool(self.cpu_count) as pool:
            pool.map(self._func, self._iterable)
            pool.close()
        return True
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) {}
	}
90717
def optimize(self):
        """"""
        subpattern = None
        if (self.content is not None and
            len(self.content) == 1 and len(self.content[0]) == 1):
            subpattern = self.content[0][0]
        if self.min == 1 and self.max == 1:
            if self.content is None:
                return NodePattern(name=self.name)
            if subpattern is not None and  self.name == subpattern.name:
                return subpattern.optimize()
        if (self.min <= 1 and isinstance(subpattern, WildcardPattern) and
            subpattern.min <= 1 and self.name == subpattern.name):
            return WildcardPattern(subpattern.content,
                                   self.min*subpattern.min,
                                   self.max*subpattern.max,
                                   subpattern.name)
        return self
12913
function mapToValues(v){
        function mapRec(e){
            if(!isAVector(e)) return e;
            return mapRec(e.get(0));
        }
        return v.map(mapRec);
    }
430890
function runMicroBenchmarks(lists, resources) {
  console.log('Run micro bench...');
  // Create adb engine to use in benchmark
  const { engine, serialized } = createEngine(lists, resources, {
    loadCosmeticFilters: true,
    loadNetworkFilters: true,
  }, true /* Also serialize engine */);

  const filters = getFiltersFromLists(lists);
  const combinedLists = filters.join('\n');
  const { networkFilters, cosmeticFilters } = parseFilters(combinedLists);
  const results = {};

  // Arguments shared among benchmarks
  const args = {
    lists,
    resources,
    engine,
    filters,
    serialized,
    networkFilters,
    cosmeticFilters,
    combinedLists,
  };

  [
    benchCosmeticsFiltersParsing,
    benchEngineCreation,
    benchEngineDeserialization,
    benchEngineSerialization,
    benchGetCosmeticTokens,
    benchGetNetworkTokens,
    benchNetworkFiltersParsing,
    benchStringHashing,
    benchStringTokenize,
    benchGetCosmeticsFilters,
  ].forEach((bench) => {
    if (bench.name.toLowerCase().includes(GREP)) {
      const suite = new Benchmark.Suite();
      suite.add(bench.name, () => bench(args)).on('cycle', (event) => {
        results[bench.name] = {
          opsPerSecond: event.target.hz,
          relativeMarginOfError: event.target.stats.rme,
          numberOfSamples: event.target.stats.sample.length,
        };
      }).run({ async: false });
    }
  });

  return {
    engineStats: {
      numFilters: engine.size,
      numCosmeticFilters: engine.cosmetics.size,
      numExceptionFilters: engine.exceptions.size,
      numImportantFilters: engine.importants.size,
      numRedirectFilters: engine.redirects.size,
    },
    microBenchmarks: results,
  };
}
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;
  }
910324
function pushTo(array) {
	return map(function (file, cb) {
		array.push(file);
		cb(null, file);
	});
}
115030
protected final void writeMapTo( Map<String,Object> map , RawDataBuffer out )
    {
    	if (map == null)
    	{
    		out.writeInt(0);
    		return;
    	}
    	
        out.writeInt(map.size());
        if (!map.isEmpty())
        {
            Iterator<Map.Entry<String,Object>> allEntries = map.entrySet().iterator();
            while (allEntries.hasNext())
            {
                Map.Entry<String,Object> entry = allEntries.next();
                out.writeUTF(entry.getKey());
                out.writeGeneric(entry.getValue());
            }
        }
    }
138897
function map(f, a)
{
	var newA = {
		ctor: '_Array',
		height: a.height,
		table: new Array(a.table.length)
	};
	if (a.height > 0)
	{
		newA.lengths = a.lengths;
	}
	for (var i = 0; i < a.table.length; i++)
	{
		newA.table[i] =
			a.height === 0
				? f(a.table[i])
				: map(f, a.table[i]);
	}
	return newA;
}
1160831
private void CalculateMap(IntRange inRange, IntRange outRange, int[] map) {
        double k = 0, b = 0;

        if (inRange.getMax() != inRange.getMin()) {
            k = (double) (outRange.getMax() - outRange.getMin()) / (double) (inRange.getMax() - inRange.getMin());
            b = (double) (outRange.getMin()) - k * inRange.getMin();
        }

        for (int i = 0; i < 256; i++) {
            int v = (int) i;

            if (v >= inRange.getMax())
                v = outRange.getMax();
            else if (v <= inRange.getMin())
                v = outRange.getMin();
            else
                v = (int) (k * v + b);

            map[i] = v;
        }
    }
1321522
function runningMap(a, fn, init) {
  return a.map(v => init = fn(v, init));
}
209687
@Override
    protected void doPerform() {
        WebElement targetElem = getFirstElement(target);
        if (targetOffset == null) {
            getActions().dragAndDrop(getFirstElement(), targetElem).perform();
        } else {
            org.openqa.selenium.Dimension size = targetElem.getSize();
            Dimension dimension = new Dimension(size.width, size.height);
            Point offsetPoint = targetOffset.offset(dimension);
            getActions().dragAndDropBy(getFirstElement(), offsetPoint.x(), offsetPoint.y()).perform();
        }
    }
156353
private RoxPayload optimize(RoxPayload payload) {
		if (store != null) {
			return payload.getOptimizer().optimize(store, payload);
		}

		return payload;
	}