本文整理汇总了Java中gnu.trove.TIntArrayList.get方法的典型用法代码示例。如果您正苦于以下问题:Java TIntArrayList.get方法的具体用法?Java TIntArrayList.get怎么用?Java TIntArrayList.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.TIntArrayList
的用法示例。
在下文中一共展示了TIntArrayList.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeInitialCentroids
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
protected void computeInitialCentroids(DocumentCentroid[] centroids,
IIntIterator documents, IIndex index) {
TIntArrayList initial = new TIntArrayList();
documents.begin();
while (documents.hasNext()) {
initial.add(documents.next());
}
Random r = new Random();
for (int i = 0; i < centroids.length; i++) {
// Choose random document.
int nextDoc = initial.get(r.nextInt(initial.size()));
TIntArrayList ar = new TIntArrayList();
ar.add(nextDoc);
centroids[i].features = Clustering.computeDocumentCentroid(
new TIntArrayListIterator(ar), index);
}
}
示例2: computeInitialCentroidsNormal
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
protected void computeInitialCentroidsNormal(DocumentCentroid[] centroids,
IIntIterator documents, IIndex index) {
TIntArrayList initial = new TIntArrayList();
documents.begin();
while (documents.hasNext()) {
initial.add(documents.next());
}
Random r = new Random();
for (int i = 0; i < centroids.length; i++) {
// Choose random document.
int nextDoc = initial.get(r.nextInt(initial.size()));
TIntArrayList ar = new TIntArrayList();
ar.add(nextDoc);
centroids[i].features = Clustering.computeDocumentCentroid(
new TIntArrayListIterator(ar), index);
}
}
示例3: calculateWidthIncrease
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
/**
* It's possible that we need to expand quick doc control's width in order to provide better visual representation
* (see https://youtrack.jetbrains.com/issue/IDEA-101425). This method calculates that width expand.
*
* @param buttonWidth icon button's width
* @param updatedText text which will be should at the quick doc control
* @return width increase to apply to the target quick doc control (zero if no additional width increase is required)
*/
private static int calculateWidthIncrease(int buttonWidth, String updatedText) {
int maxLineWidth = 0;
TIntArrayList lineWidths = new TIntArrayList();
for (String lineText : StringUtil.split(updatedText, "<br/>")) {
String html = HintUtil.prepareHintText(lineText, HintUtil.getInformationHint());
int width = new JLabel(html).getPreferredSize().width;
maxLineWidth = Math.max(maxLineWidth, width);
lineWidths.add(width);
}
if (!lineWidths.isEmpty()) {
int firstLineAvailableTrailingWidth = maxLineWidth - lineWidths.get(0);
if (firstLineAvailableTrailingWidth >= buttonWidth) {
return 0;
}
else {
return buttonWidth - firstLineAvailableTrailingWidth;
}
}
return 0;
}
示例4: fillMappings
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
@Override
protected void fillMappings(@NotNull ArrangementMatchingRulesControl control, @NotNull List<int[]> mappings) {
TIntArrayList rows = control.getSelectedModelRows();
rows.reverse();
int top = -1;
for (int i = 0; i < rows.size(); i++) {
int row = rows.get(i);
if (row == top + 1) {
mappings.add(new int[] { row, row });
top++;
}
else {
mappings.add(new int[]{ row, row - 1 });
}
}
}
示例5: actionPerformed
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
ArrangementMatchingRulesControl control = getRulesControl(e);
if (control == null) {
return;
}
control.hideEditor();
TIntArrayList rows = control.getSelectedModelRows();
ArrangementMatchingRulesModel model = control.getModel();
int rowToEdit;
if (rows.size() == 1) {
rowToEdit = rows.get(0) + 1;
model.insertRow(rowToEdit, new Object[] {createNewRule(control)});
}
else {
rowToEdit = model.getSize();
model.add(createNewRule(control));
}
showEditor(control, rowToEdit);
control.getSelectionModel().setSelectionInterval(rowToEdit, rowToEdit);
scrollRowToVisible(control, rowToEdit);
}
示例6: patchInstructionOffsets
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
private void patchInstructionOffsets(@Nullable TIntArrayList offsets, int add) {
if (offsets == null) return;
for (int i = 0; i < offsets.size(); i++) {
int offset = offsets.get(i);
BranchingInstruction instruction = (BranchingInstruction)myCurrentFlow.getInstructions().get(offset);
instruction.offset += add;
LOG.assertTrue(instruction.offset >= 0);
}
poolIntArray(offsets);
}
示例7: executeImpl
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
protected static boolean executeImpl(IndexPatternSearch.SearchParameters queryParameters,
Processor<IndexPatternOccurrence> consumer) {
final IndexPatternProvider patternProvider = queryParameters.getPatternProvider();
final PsiFile file = queryParameters.getFile();
TIntArrayList commentStarts = new TIntArrayList();
TIntArrayList commentEnds = new TIntArrayList();
final CharSequence chars = file.getViewProvider().getContents();
findCommentTokenRanges(file, chars, queryParameters.getRange(), commentStarts, commentEnds);
TIntArrayList occurrences = new TIntArrayList(1);
IndexPattern[] patterns = patternProvider != null ? patternProvider.getIndexPatterns() : null;
for (int i = 0; i < commentStarts.size(); i++) {
int commentStart = commentStarts.get(i);
int commentEnd = commentEnds.get(i);
occurrences.resetQuick();
if (patternProvider != null) {
for (int j = patterns.length - 1; j >=0; --j) {
if (!collectPatternMatches(patterns[j], chars, commentStart, commentEnd, file, queryParameters.getRange(), consumer, occurrences)) {
return false;
}
}
}
else {
if (!collectPatternMatches(queryParameters.getPattern(), chars, commentStart, commentEnd, file, queryParameters.getRange(),
consumer, occurrences)) {
return false;
}
}
}
return true;
}
示例8: onMouseClicked
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
private void onMouseClicked(@NotNull MouseEvent e) {
final int count = e.getClickCount();
if (count != 2) {
return;
}
final TIntArrayList rows = getSelectedModelRows();
if (rows.size() != 1) {
return;
}
final int row = rows.get(0);
showEditor(row);
scrollRowToVisible(row);
}
示例9: fillMappings
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
@Override
protected void fillMappings(@NotNull ArrangementMatchingRulesControl control, @NotNull List<int[]> mappings) {
TIntArrayList rows = control.getSelectedModelRows();
int bottom = control.getModel().getSize();
for (int i = 0; i < rows.size(); i++) {
int row = rows.get(i);
if (row == bottom - 1) {
mappings.add(new int[] { row, row });
bottom--;
}
else {
mappings.add(new int[]{ row, row + 1 });
}
}
}
示例10: actionPerformed
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
ArrangementMatchingRulesControl control = getRulesControl(e);
if (control == null) {
return;
}
TIntArrayList rows = control.getSelectedModelRows();
if (rows.size() != 1) {
return;
}
final int row = rows.get(0);
control.showEditor(row);
scrollRowToVisible(control, row);
}
示例11: getContainingIds
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
@NotNull
@Override
public <Key> IdIterator getContainingIds(@NotNull StubIndexKey<Key, ?> indexKey,
@NotNull Key dataKey,
@NotNull final Project project,
@NotNull final GlobalSearchScope scope) {
final TIntArrayList result = new TIntArrayList();
doProcessStubs(indexKey, dataKey, project, scope, new StubIdListContainerAction(null, project) {
@Override
protected boolean process(int id, StubIdList value) {
result.add(id);
return true;
}
});
return new IdIterator() {
int cursor = 0;
@Override
public boolean hasNext() {
return cursor < result.size();
}
@Override
public int next() {
return result.get(cursor++);
}
@Override
public int size() {
return result.size();
}
};
}
示例12: PasteProcessor
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
public PasteProcessor(GuiEditor editor, final ArrayList<RadComponent> componentsToPaste,
final TIntArrayList xs, final TIntArrayList ys) {
myEditor = editor;
myComponentsToPaste = componentsToPaste;
myGridInsertProcessor = new GridInsertProcessor(editor);
myPastedComponentList = new PastedComponentList();
int minX = Integer.MAX_VALUE;
int minY = Integer.MAX_VALUE;
// TIntArrayList.min() is broken
for(int i=0; i<xs.size(); i++) {
minX = Math.min(minX, xs.get(i));
}
for(int i=0; i<ys.size(); i++) {
minY = Math.min(minY, ys.get(i));
}
myDX = new int[xs.size()];
myDY = new int[ys.size()];
for(int i=0; i<xs.size(); i++) {
myDX [i] = xs.get(i) - minX;
}
for(int i=0; i<ys.size(); i++) {
myDY [i] = ys.get(i) - minY;
}
int myMinRow = Integer.MAX_VALUE;
int myMinCol = Integer.MAX_VALUE;
for(RadComponent component: myComponentsToPaste) {
myMinRow = Math.min(myMinRow, component.getConstraints().getRow());
myMinCol = Math.min(myMinCol, component.getConstraints().getColumn());
}
this.myMinRow = myMinRow;
this.myMinCol = myMinCol;
StatusBar.Info.set(UIDesignerBundle.message("paste.choose.destination.prompt"), myEditor.getProject());
}
示例13: integrateTestIndex
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
protected void integrateTestIndex(int step, IIndex idx, IIndex originalIndex, TIntArrayList docs, int numTotalSteps) {
if (docs.size() == 0)
return;
String catName = idx.getCategoryDB().getCategoryName((short) 0);
int positive = idx.getClassificationDB().getCategoryDocumentsCount((short) 0);
if (positive <= numTotalSteps)
numTotalSteps = positive;
if (numTotalSteps == 0)
numTotalSteps = 1;
int numDocs = docs.size();
int perStep = numDocs / numTotalSteps;
if (numDocs % numTotalSteps != 0)
perStep++;
TroveMainIndexBuilder builder = new TroveMainIndexBuilder(idx);
int startVal = perStep * step;
int endVal = (startVal + perStep) <= docs.size() ? startVal + perStep : docs.size();
for (int i = startVal; i < endVal; i++) {
int docID = docs.get(i);
String docName = originalIndex.getDocumentDB().getDocumentName(docID);
docName += "_" + System.currentTimeMillis();
// Prepare categories.
ArrayList<String> catsToInsert = new ArrayList<String>();
IShortIterator cats = originalIndex.getClassificationDB().getDocumentCategories(docID);
while (cats.hasNext()) {
short curCatID = cats.next();
String curCatName = originalIndex.getCategoryDB().getCategoryName(curCatID);
if (curCatName.equals(catName))
catsToInsert.add(curCatName);
}
// Prepare features.
ArrayList<String> featsToInsert = new ArrayList<String>();
IIntIterator feats = originalIndex.getContentDB().getDocumentFeatures(docID);
while (feats.hasNext()) {
int featID = feats.next();
featsToInsert.add(originalIndex.getFeatureDB().getFeatureName(featID));
}
builder.addDocument(docName, featsToInsert.toArray(new String[0]), catsToInsert.toArray(new String[0]));
}
JatecsLogger.status().println("After integration the validation contain " + idx.getDocumentDB().getDocumentsCount() + " document(s)");
}
示例14: replace
import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
@SuppressWarnings("AssignmentToForLoopParameter")
@Override
public void replace(@NotNull ArrangementEntryWrapper<E> newWrapper,
@NotNull ArrangementEntryWrapper<E> oldWrapper,
@Nullable ArrangementEntryWrapper<E> previous,
@Nullable ArrangementEntryWrapper<E> next,
@NotNull Context<E> context)
{
// Calculate blank lines before the arrangement.
int blankLinesBefore = 0;
TIntArrayList lineFeedOffsets = new TIntArrayList();
int oldStartLine = context.document.getLineNumber(oldWrapper.getStartOffset());
if (oldStartLine > 0) {
int lastLineFeed = context.document.getLineStartOffset(oldStartLine) - 1;
lineFeedOffsets.add(lastLineFeed);
for (int i = lastLineFeed - 1 - myParentShift; i >= 0; i--) {
i = CharArrayUtil.shiftBackward(myParentText, i, " \t");
if (myParentText.charAt(i) == '\n') {
blankLinesBefore++;
lineFeedOffsets.add(i + myParentShift);
}
else {
break;
}
}
}
ArrangementEntryWrapper<E> parentWrapper = oldWrapper.getParent();
int desiredBlankLinesNumber = getBlankLines(context, parentWrapper, newWrapper, previous, next);
if (desiredBlankLinesNumber == blankLinesBefore && newWrapper.equals(oldWrapper)) {
return;
}
String newEntryText = myParentText.substring(newWrapper.getStartOffset() - myParentShift, newWrapper.getEndOffset() - myParentShift);
int lineFeedsDiff = desiredBlankLinesNumber - blankLinesBefore;
if (lineFeedsDiff == 0 || desiredBlankLinesNumber < 0) {
context.addMoveInfo(newWrapper.getStartOffset() - myParentShift,
newWrapper.getEndOffset() - myParentShift,
oldWrapper.getStartOffset());
context.document.replaceString(oldWrapper.getStartOffset(), oldWrapper.getEndOffset(), newEntryText);
return;
}
if (lineFeedsDiff > 0) {
// Insert necessary number of blank lines.
StringBuilder buffer = new StringBuilder(StringUtil.repeat("\n", lineFeedsDiff));
buffer.append(newEntryText);
context.document.replaceString(oldWrapper.getStartOffset(), oldWrapper.getEndOffset(), buffer);
}
else {
// Cut exceeding blank lines.
int replacementStartOffset = lineFeedOffsets.get(-lineFeedsDiff) + 1;
context.document.replaceString(replacementStartOffset, oldWrapper.getEndOffset(), newEntryText);
}
// Update wrapper ranges.
ArrangementEntryWrapper<E> parent = oldWrapper.getParent();
if (parent == null) {
return;
}
Deque<ArrangementEntryWrapper<E>> parents = new ArrayDeque<ArrangementEntryWrapper<E>>();
do {
parents.add(parent);
parent.setEndOffset(parent.getEndOffset() + lineFeedsDiff);
parent = parent.getParent();
}
while (parent != null);
while (!parents.isEmpty()) {
for (ArrangementEntryWrapper<E> wrapper = parents.removeLast().getNext(); wrapper != null; wrapper = wrapper.getNext()) {
wrapper.applyShift(lineFeedsDiff);
}
}
}
示例15: getDisplayValue
import gnu.trove.TIntArrayList; //导入方法依赖的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();
}