当前位置: 首页>>代码示例>>Java>>正文


Java ArrayUtil.newIntArray方法代码示例

本文整理汇总了Java中com.intellij.util.ArrayUtil.newIntArray方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtil.newIntArray方法的具体用法?Java ArrayUtil.newIntArray怎么用?Java ArrayUtil.newIntArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.ArrayUtil的用法示例。


在下文中一共展示了ArrayUtil.newIntArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sortItemsAccordingToSettings

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
public static List<Pair<String, Boolean>> sortItemsAccordingToSettings(List<Pair<String, Boolean>> names, final CodeStyleSettings settings) {
  int[] entryForName = ArrayUtil.newIntArray(names.size());
  PackageEntry[] entries = settings.IMPORT_LAYOUT_TABLE.getEntries();
  for(int i = 0; i < names.size(); i++){
    Pair<String, Boolean> pair = names.get(i);
    String packageName = pair.getFirst();
    Boolean isStatic = pair.getSecond();
    entryForName[i] = findEntryIndex(packageName, isStatic, entries);
  }

  List<Pair<String, Boolean>> resultList = new ArrayList<Pair<String, Boolean>>(names.size());
  for(int i = 0; i < entries.length; i++){
    for(int j = 0; j < names.size(); j++){
      if (entryForName[j] == i){
        resultList.add(names.get(j));
        names.set(j, null);
      }
    }
  }
  for (Pair<String, Boolean> name : names) {
    if (name != null) resultList.add(name);
  }
  return resultList;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ImportHelper.java

示例2: list

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
public static int[] list(int id) {
  try {
    r.lock();
    try {
      final DataInputStream input = readAttribute(id, ourChildrenAttr);
      if (input == null) return ArrayUtil.EMPTY_INT_ARRAY;

      final int count = DataInputOutputUtil.readINT(input);
      final int[] result = ArrayUtil.newIntArray(count);
      int prevId = id;
      for (int i = 0; i < count; i++) {
        prevId = result[i] = DataInputOutputUtil.readINT(input) + prevId;
      }
      input.close();
      return result;
    }
    finally {
      r.unlock();
    }
  }
  catch (Throwable e) {
    throw DbConnection.handleError(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:FSRecords.java

示例3: calculatePermutation

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
private static int[] calculatePermutation(PsiMethodCallExpression call, PsiParameterList parameterList) {
  final PsiExpressionList argumentList = call.getArgumentList();
  final PsiExpression[] args = argumentList.getExpressions();
  final int[] out = ArrayUtil.newIntArray(args.length);
  for (int i = 0; i < args.length; i++) {
    final PsiExpression arg = args[i];
    final PsiParameter parameter = (PsiParameter)((PsiReference)arg).resolve();
    out[i] = parameterList.getParameterIndex(parameter);
  }
  return out;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:DelegationUtils.java

示例4: listRoots

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
static int[] listRoots() {
  try {
    r.lock();
    try {
      final DataInputStream input = readAttribute(1, ourChildrenAttr);
      if (input == null) return ArrayUtil.EMPTY_INT_ARRAY;

      try {
        final int count = DataInputOutputUtil.readINT(input);
        int[] result = ArrayUtil.newIntArray(count);
        int prevId = 0;
        for (int i = 0; i < count; i++) {
          DataInputOutputUtil.readINT(input); // Name
          prevId = result[i] = DataInputOutputUtil.readINT(input) + prevId; // Id
        }
        return result;
      }
      finally {
        input.close();
      }
    }
    finally {
      r.unlock();
    }
  }
  catch (Throwable e) {
    throw DbConnection.handleError(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:FSRecords.java

示例5: enumerate

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
public int[] enumerate(T[] objects, final int startShift, final int endCut) {
  int[] idx = ArrayUtil.newIntArray(objects.length - startShift - endCut);
  for (int i = startShift; i < (objects.length - endCut); i++) {
    final T object = objects[i];
    final int number = enumerate(object);
    idx[i - startShift] = number;
  }
  return idx;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:Enumerator.java

示例6: getDisplayValue

import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Override
public String getDisplayValue() {
  String displayText = myDisplayText;
  if (displayText != null) return displayText;
  XmlAttributeValue value = getValueElement();
  if (value == null) return null;
  PsiElement firstChild = value.getFirstChild();
  if (firstChild == null) return null;
  ASTNode child = firstChild.getNode();
  TextRange valueTextRange = new TextRange(0, value.getTextLength());
  if (child != null && child.getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER) {
    valueTextRange = new TextRange(child.getTextLength(), valueTextRange.getEndOffset());
    child = child.getTreeNext();
  }
  final TIntArrayList gapsStarts = new TIntArrayList();
  final TIntArrayList gapsShifts = new TIntArrayList();
  StringBuilder buffer = new StringBuilder(getTextLength());
  while (child != null) {
    final int start = buffer.length();
    IElementType elementType = child.getElementType();
    if (elementType == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER) {
      valueTextRange =
        new TextRange(valueTextRange.getStartOffset(), child.getTextRange().getStartOffset() - value.getTextRange().getStartOffset());
      break;
    }
    if (elementType == XmlTokenType.XML_CHAR_ENTITY_REF) {
      buffer.append(XmlUtil.getCharFromEntityRef(child.getText()));
    }
    else if (elementType == XmlElementType.XML_ENTITY_REF) {
      buffer.append(XmlUtil.getEntityValue((XmlEntityRef)child));
    }
    else {
      appendChildToDisplayValue(buffer, child);
    }

    int end = buffer.length();
    int originalLength = child.getTextLength();
    if (end - start != originalLength) {
      gapsStarts.add(start);
      gapsShifts.add(originalLength - (end - start));
    }
    child = child.getTreeNext();
  }
  int[] gapDisplayStarts = ArrayUtil.newIntArray(gapsShifts.size());
  int[] gapPhysicalStarts = ArrayUtil.newIntArray(gapsShifts.size());
  int currentGapsSum = 0;
  for (int i = 0; i < gapDisplayStarts.length; i++) {
    currentGapsSum += gapsShifts.get(i);
    gapDisplayStarts[i] = gapsStarts.get(i);
    gapPhysicalStarts[i] = gapDisplayStarts[i] + currentGapsSum;
  }
  myGapDisplayStarts = gapDisplayStarts;
  myGapPhysicalStarts = gapPhysicalStarts;
  myValueTextRange = valueTextRange;
  return myDisplayText = buffer.toString();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:57,代码来源:XmlAttributeImpl.java


注:本文中的com.intellij.util.ArrayUtil.newIntArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。