Java 类com.intellij.util.containers.ConcurrentIntObjectMap 实例源码

项目:intellij-ce-playground    文件:RefResolveServiceImpl.java   
private void storeIds(@NotNull ConcurrentIntObjectMap<int[]> fileToForwardIds) {
  int forwardSize = 0;
  int backwardSize = 0;
  final TIntObjectHashMap<TIntArrayList> fileToBackwardIds = new TIntObjectHashMap<TIntArrayList>(fileToForwardIds.size());
  for (ConcurrentIntObjectMap.IntEntry<int[]> entry : fileToForwardIds.entries()) {
    int fileId = entry.getKey();
    int[] forwardIds = entry.getValue();
    forwardSize += forwardIds.length;
    for (int forwardId : forwardIds) {
      TIntArrayList backIds = fileToBackwardIds.get(forwardId);
      if (backIds == null) {
        backIds = new TIntArrayList();
        fileToBackwardIds.put(forwardId, backIds);
      }
      backIds.add(fileId);
      backwardSize++;
    }
  }
  log("backwardSize = " + backwardSize);
  log("forwardSize = " + forwardSize);
  log("fileToForwardIds.size() = "+fileToForwardIds.size());
  log("fileToBackwardIds.size() = "+fileToBackwardIds.size());
  assert forwardSize == backwardSize;

  // wrap in read action so that sudden quit (in write action) would not interrupt us
  myApplication.runReadAction(new Runnable() {
    @Override
    public void run() {
      if (!myApplication.isDisposed()) {
        fileToBackwardIds.forEachEntry(new TIntObjectProcedure<TIntArrayList>() {
          @Override
          public boolean execute(int fileId, TIntArrayList backIds) {
            storage.addAll(fileId, backIds.toNativeArray());
            return true;
          }
        });
      }
    }
  });
}
项目:intellij-ce-playground    文件:PersistentFSImpl.java   
@Override
public void clearIdCache() {
  // remove all except myRootsById contents
  for (Iterator<ConcurrentIntObjectMap.IntEntry<VirtualFileSystemEntry>> iterator = myIdToDirCache.entries().iterator(); iterator.hasNext(); ) {
    ConcurrentIntObjectMap.IntEntry<VirtualFileSystemEntry> entry = iterator.next();
    int id = entry.getKey();
    if (!myRootsById.containsKey(id)) {
      iterator.remove();
    }
  }
}
项目:intellij-ce-playground    文件:FSRecords.java   
@NotNull
public static TIntArrayList getParents(int id, @NotNull ConcurrentIntObjectMap<?> idCache) {
  TIntArrayList result = new TIntArrayList(10);
  r.lock();
  try {
    int parentId;
    do {
      result.add(id);
      if (idCache.containsKey(id)) {
        break;
      }
      parentId = getRecordInt(id, PARENT_OFFSET);
      if (parentId == id || result.size() % 128 == 0 && result.contains(parentId)) {
        LOG.error("Cyclic parent child relations in the database. id = " + parentId);
        return result;
      }
      id = parentId;
    } while (parentId != 0);
  }
  catch (Throwable e) {
    throw DbConnection.handleError(e);
  }
  finally {
    r.unlock();
  }
  return result;
}
项目:intellij-ce-playground    文件:Key.java   
/**
 * @deprecated access to Key via its name is a kind of hack, use Key instance directly instead
 */
@Nullable
public static Key<?> findKeyByName(String name) {
  for (ConcurrentIntObjectMap.IntEntry<Key> key : allKeys.entries()) {
    if (name.equals(key.getValue().myName)) {
      //noinspection unchecked
      return key.getValue();
    }
  }
  return null;
}
项目:consulo    文件:Iconable.java   
public static void put(@Nonnull UserDataHolder holder, Icon icon, int flags) {
  ConcurrentIntObjectMap<Icon> map = holder.getUserData(LAST_COMPUTED_ICON);
  if (icon == null) {
    if (map != null) {
      map.remove(flags);
    }
  }
  else {
    if (map == null) {
      map = ((UserDataHolderEx)holder).putUserDataIfAbsent(LAST_COMPUTED_ICON, ContainerUtil.createConcurrentIntObjectMap());
    }
    map.put(flags, icon);
  }
}
项目:consulo    文件:PersistentFSImpl.java   
@Override
public void clearIdCache() {
  // remove all except myRootsById contents
  for (Iterator<ConcurrentIntObjectMap.IntEntry<VirtualFileSystemEntry>> iterator = myIdToDirCache.entries().iterator(); iterator.hasNext(); ) {
    ConcurrentIntObjectMap.IntEntry<VirtualFileSystemEntry> entry = iterator.next();
    int id = entry.getKey();
    if (!myRootsById.containsKey(id)) {
      iterator.remove();
    }
  }
}
项目:consulo    文件:FSRecords.java   
@Nonnull
public static TIntArrayList getParents(int id, @Nonnull ConcurrentIntObjectMap<?> idCache) {
  TIntArrayList result = new TIntArrayList(10);
  r.lock();
  try {
    int parentId;
    do {
      result.add(id);
      if (idCache.containsKey(id)) {
        break;
      }
      parentId = getRecordInt(id, PARENT_OFFSET);
      if (parentId == id || result.size() % 128 == 0 && result.contains(parentId)) {
        LOG.error("Cyclic parent child relations in the database. id = " + parentId);
        return result;
      }
      id = parentId;
    } while (parentId != 0);
  }
  catch (Throwable e) {
    throw DbConnection.handleError(e);
  }
  finally {
    r.unlock();
  }
  return result;
}
项目:consulo    文件:KeyRegistryImpl.java   
@Override
public Key<?> findKeyByName(String name, Function<Key<?>, String> nameFunc) {
  for (ConcurrentIntObjectMap.IntEntry<Key> key : myAllKeys.entries()) {
    if (name.equals(nameFunc.fun(key.getValue()))) {
      //noinspection unchecked
      return key.getValue();
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:Client.java   
public ChannelFutureAwarePromise(int messageId, ConcurrentIntObjectMap<?> messageCallbackMap) {
  this.messageId = messageId;
  this.messageCallbackMap = messageCallbackMap;
}
项目:consulo    文件:Iconable.java   
@Nullable
public static Icon get(@Nonnull UserDataHolder holder, int flags) {
  ConcurrentIntObjectMap<Icon> map = holder.getUserData(LAST_COMPUTED_ICON);
  return map == null ? null : map.get(flags);
}