Initialize the NN cache.

@param scratch Scratch space
@param bestd Best distance
@param besti Best index
768967
private static void initializeNNCache(double[] scratch, double[] bestd, int[] besti) {
    final int size = bestd.length;
    Arrays.fill(bestd, Double.POSITIVE_INFINITY);
    Arrays.fill(besti, -1);
    for(int x = 0, p = 0; x < size; x++) {
      assert (p == MatrixParadigm.triangleSize(x));
      double bestdx = Double.POSITIVE_INFINITY;
      int bestix = -1;
      for(int y = 0; y < x; y++, p++) {
        final double v = scratch[p];
        if(v < bestd[y]) {
          bestd[y] = v;
          besti[y] = x;
        }
        if(v < bestdx) {
          bestdx = v;
          bestix = y;
        }
      }
      bestd[x] = bestdx;
      besti[x] = bestix;
    }
  }
64350
public static void setMainCache(String cacheName) {
		if (StrKit.isBlank(cacheName))
			throw new IllegalArgumentException("cacheName can not be blank");
		cacheName = cacheName.trim();
		Cache cache = cacheMap.get(cacheName);
		if (cache == null)
			throw new IllegalArgumentException("the cache not exists: " + cacheName);
		
		Redis.mainCache = cache;
	}
283220
private synchronized void initCache() {

    if (this.cache == null) {
      ClasspathFolder rootFolder = new ClasspathFolder(null, "");
      Set<String> resourceNames = this.reflectionUtil.findResourceNames("", true, ConstantFilter.getInstance(true));
      List<ClasspathFile> fileList = new ArrayList<>(resourceNames.size());
      for (String resource : resourceNames) {
        ResourcePathNode<Void> path = ResourcePathNode.create(resource);
        ClasspathFolder parent = createFolderRecursive(path.getParent(), rootFolder);
        ClasspathFile file = new ClasspathFile(parent, path.getName());
        parent.children.add(file);
        fileList.add(file);
      }
      this.cache = new Cache(rootFolder, fileList);
    }
  }
1245219
public static <K, V> Cache<K, V> createCache(int maximumSize, long expiryDurationSeconds) {
        Cache<K, V> cache = CacheBuilder.newBuilder().maximumSize(maximumSize)
                .expireAfterAccess(expiryDurationSeconds, TimeUnit.SECONDS).build();
        return cache;
    }
1230738
function(newinput, bestmatch) {
		var matches = this._matches,
			oldindex = -1,
			oldrating = -1,
			newrating = edb.InputPlugin._rateone(newinput.type, bestmatch);
		matches.forEach(function oldbestmatch(match, i) {
			oldrating = edb.InputPlugin._rateone(match.type, bestmatch);
			if (oldrating > -1 && oldrating <= newrating) {
				oldindex = i;
			}
		});
		if (oldindex > -1) {
			matches[oldindex] = newinput;
		} else {
			matches.push(newinput);
		}
	}
180894
public void insert(final AbstractInsnNode location,
            final AbstractInsnNode insn) {
        ++size;
        AbstractInsnNode next = location.next;
        if (next == null) {
            last = insn;
        } else {
            next.prev = insn;
        }
        location.next = insn;
        insn.next = next;
        insn.prev = location;
        cache = null;
        insn.index = 0; // insn now belongs to an InsnList
    }
1157640
private void initializeCacheData(int cacheSize)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && (tc.isEntryEnabled() || tcOOM.isEntryEnabled()))
            Tr.entry(tc.isEntryEnabled() ? tc : tcOOM,
                     "initializeCacheData : " + ivCache.getName() + " preferred size = " +
                                     ivPreferredMaxSize);

        ivPreferredMaxSize = cacheSize;

        // Define an internal upper limit to the cache size. This is similar
        // to the 'hard' limit, but would never be enforced; it is merely
        // used to determine a point at which the eviction strategy should
        // dynamically tune itself to become more aggressive.               d112258
        ivUpperLimit = (long) (ivPreferredMaxSize * 1.1); // 10% over cache size

        // Give the cache a little breathing room (or buffer) below the
        // soft limit. By reducing to this far below the soft limit, it
        // is less likely that the next sweep will have to do anything.
        ivSoftLimitBuffer = ivPreferredMaxSize / 100; // 1% of the Cache Size
        if (ivSoftLimitBuffer > 50) // Don't let this get too big.
            ivSoftLimitBuffer = 50;

        if (isTraceOn && (tc.isEntryEnabled() || tcOOM.isEntryEnabled()))
            Tr.exit(tc.isEntryEnabled() ? tc : tcOOM,
                    "initializeCacheData : " + ivCache.getName() + " preferred size = "
                                    + ivPreferredMaxSize + " limit = " + ivUpperLimit +
                                    ", buffer = " + ivSoftLimitBuffer);
    }
426869
private void init(){
		// We are going to use a linked hash map to maintain our sliding window
		slidingWindow=new LinkedHashMap<String,Integer>(windowSize+1, .75F, false){
            protected boolean removeEldestEntry(Map.Entry<String,Integer> eldest){
                return size()>windowSize;                                  
            }
        };
	}
656289
public void setLargestKey(int chunkIdx, byte[] largestKeyInChunk) {
        maxKeyPerChunk[chunkIdx] = largestKeyInChunk;
        filledUpTo = Math.max(filledUpTo, chunkIdx);
        indexBuffer.position(chunkIdx * keySize);
        indexBuffer.put(largestKeyInChunk);
    }
481279
private void setAcceptedLocalCandidate(TransportCandidate bestLocalCandidate) {
        for (int i = 0; i < resolver.getCandidateCount(); i++) {
            // TODO FIX The EQUAL Sentence
            if (resolver.getCandidate(i).getIp().equals(bestLocalCandidate.getIp())
                    && resolver.getCandidate(i).getPort() == bestLocalCandidate.getPort()) {
                acceptedLocalCandidate = resolver.getCandidate(i);
                return;
            }
        }
        LOGGER.fine("BEST: ip=" + bestLocalCandidate.getIp() + " port=" + bestLocalCandidate.getPort() + " has not been offered.");
        // throw new XMPPException("Local transport candidate has not be offered.");
    }
697016
public static void initialize()
    {
        if (InfinispanCache.get().exists(Association.IDCACHE)) {
            InfinispanCache.get().<Long, Association>getCache(Association.IDCACHE).clear();
        } else {
            InfinispanCache.get().<Long, Association>getCache(Association.IDCACHE)
                            .addListener(new CacheLogListener(Association.LOG));
        }
    }
343649
public static synchronized void init(Context context) {
        mContext = context;

        // Set the appropriate log TAG
        setTAG(QuickUtils.system.getApplicationNameByContext());

        // resets all timestamps
        QuickUtils.timer.resetAllTimestamps();

        // init Rest
        QuickUtils.rest.init();

        // init image cache
        QuickUtils.imageCache.initialize(context);

        // init the objects cache
        try {
            cacheMagic.init(4096); // in bytes
        } catch (Exception e) {
           QuickUtils.log.e("Error initing cache");
        }
    }
626851
public void initialize() {
		mIsForceStop = false;
		mTagStack.clear();
		mTagValueCache.clear();
		mTagAttrCache.clear();
		mCurrentTagKey = null;
	}
1266198
public void add(final AbstractInsnNode insn) {
        ++size;
        if (last == null) {
            first = insn;
            last = insn;
        } else {
            last.next = insn;
            insn.prev = last;
        }
        last = insn;
        cache = null;
        insn.index = 0; // insn now belongs to an InsnList
    }
780377
public static void initialize()
    {
        if (InfinispanCache.get().exists(AccessType.UUIDCACHE)) {
            InfinispanCache.get().<UUID, AccessType>getCache(AccessType.UUIDCACHE).clear();
        } else {
            InfinispanCache.get().<UUID, AccessType>getCache(AccessType.UUIDCACHE)
                            .addListener(new CacheLogListener(AccessType.LOG));
        }
        if (InfinispanCache.get().exists(AccessType.IDCACHE)) {
            InfinispanCache.get().<Long, AccessType>getCache(AccessType.IDCACHE).clear();
        } else {
            InfinispanCache.get().<Long, AccessType>getCache(AccessType.IDCACHE)
                            .addListener(new CacheLogListener(AccessType.LOG));
        }
        if (InfinispanCache.get().exists(AccessType.NAMECACHE)) {
            InfinispanCache.get().<String, AccessType>getCache(AccessType.NAMECACHE).clear();
        } else {
            InfinispanCache.get().<String, AccessType>getCache(AccessType.NAMECACHE)
                            .addListener(new CacheLogListener(AccessType.LOG));
        }
        AccessCache.initialize();
    }
428906
boolean initActiveLandmarks(int fromNode, int toNode, int[] activeLandmarkIndices,
                                int[] activeFroms, int[] activeTos, boolean reverse) {
        if (fromNode < 0 || toNode < 0)
            throw new IllegalStateException("from " + fromNode + " and to "
                    + toNode + " nodes have to be 0 or positive to init landmarks");

        int subnetworkFrom = subnetworkStorage.getSubnetwork(fromNode);
        int subnetworkTo = subnetworkStorage.getSubnetwork(toNode);
        if (subnetworkFrom <= UNCLEAR_SUBNETWORK || subnetworkTo <= UNCLEAR_SUBNETWORK)
            return false;
        if (subnetworkFrom != subnetworkTo) {
            throw new ConnectionNotFoundException("Connection between locations not found. Different subnetworks " + subnetworkFrom + " vs. " + subnetworkTo, new HashMap<String, Object>());
        }

        int[] tmpIDs = landmarkIDs.get(subnetworkFrom);

        // kind of code duplication to approximate
        List<Map.Entry<Integer, Integer>> list = new ArrayList<>(tmpIDs.length);
        for (int lmIndex = 0; lmIndex < tmpIDs.length; lmIndex++) {
            int fromWeight = getFromWeight(lmIndex, toNode) - getFromWeight(lmIndex, fromNode);
            int toWeight = getToWeight(lmIndex, fromNode) - getToWeight(lmIndex, toNode);

            list.add(new MapEntry<>(reverse
                    ? Math.max(-fromWeight, -toWeight)
                    : Math.max(fromWeight, toWeight), lmIndex));
        }

        Collections.sort(list, SORT_BY_WEIGHT);

        if (activeLandmarkIndices[0] >= 0) {
            IntHashSet set = new IntHashSet(activeLandmarkIndices.length);
            set.addAll(activeLandmarkIndices);
            int existingLandmarkCounter = 0;
            final int COUNT = Math.min(activeLandmarkIndices.length - 2, 2);
            for (int i = 0; i < activeLandmarkIndices.length; i++) {
                if (i >= activeLandmarkIndices.length - COUNT + existingLandmarkCounter) {
                    // keep at least two of the previous landmarks (pick the best)
                    break;
                } else {
                    activeLandmarkIndices[i] = list.get(i).getValue();
                    if (set.contains(activeLandmarkIndices[i]))
                        existingLandmarkCounter++;
                }
            }

        } else {
            for (int i = 0; i < activeLandmarkIndices.length; i++) {
                activeLandmarkIndices[i] = list.get(i).getValue();
            }
        }

        // store weight values of active landmarks in 'cache' arrays
        for (int i = 0; i < activeLandmarkIndices.length; i++) {
            int lmIndex = activeLandmarkIndices[i];
            activeFroms[i] = getFromWeight(lmIndex, toNode);
            activeTos[i] = getToWeight(lmIndex, toNode);
        }
        return true;
    }
1066877
private static void addCacheInfoUpdate(CacheStatus cacheStatus) {
    long cacheSize = cacheStatus.size;
    synchronized (baseDirSize) {
      Long dirSize = baseDirSize.get(cacheStatus.getBaseDir());
      if( dirSize == null ) {
        dirSize = Long.valueOf(cacheSize);
      } else {
        dirSize += cacheSize;
      }
      baseDirSize.put(cacheStatus.getBaseDir(), dirSize);
    }
    synchronized (baseDirNumberSubDir) {
      Integer dirSubDir = baseDirNumberSubDir.get(cacheStatus.getBaseDir());
      if( dirSubDir == null ) {
        dirSubDir = 1;
      } else {
        dirSubDir += 1;
      }
      baseDirNumberSubDir.put(cacheStatus.getBaseDir(), dirSubDir);
    }
  }