Java Code Examples for com.intellij.util.ArrayUtil#realloc()
The following examples show how to use
com.intellij.util.ArrayUtil#realloc() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CsvTableEditorSwing.java From intellij-csv-validator with Apache License 2.0 | 6 votes |
@Override protected void updateEditorLayout() { int currentColumnCount = this.getTableModel().getColumnCount(); int[] columnWidths = getFileEditorState().getColumnWidths(); int prevColumnCount = columnWidths.length; if (prevColumnCount != currentColumnCount) { columnWidths = ArrayUtil.realloc(columnWidths, currentColumnCount); if (prevColumnCount < currentColumnCount) { Arrays.fill(columnWidths, prevColumnCount, currentColumnCount, CsvEditorSettings.getInstance().getTableDefaultColumnWidth()); } getFileEditorState().setColumnWidths(columnWidths); } float zoomFactor = getZoomFactor(); for (int i = 0; i < currentColumnCount; ++i) { TableColumn column = this.tblEditor.getColumnModel().getColumn(i); column.setPreferredWidth(Math.round(columnWidths[i] * zoomFactor)); column.setWidth(Math.round(columnWidths[i] * zoomFactor)); } this.updateRowHeights(null); panelInfo.setVisible(getFileEditorState().showInfoPanel()); }
Example 2
Source File: IElementType.java From consulo with Apache License 2.0 | 6 votes |
protected IElementType(@Nonnull @NonNls String debugName, @Nullable Language language, boolean register) { myDebugName = debugName; myLanguage = language == null ? Language.ANY : language; if (register) { synchronized (lock) { myIndex = size++; LOG.assertTrue(myIndex < MAX_INDEXED_TYPES, "Too many element types registered. Out of (short) range."); IElementType[] newRegistry = myIndex >= ourRegistry.length ? ArrayUtil.realloc(ourRegistry, ourRegistry.length * 3 / 2 + 1, ARRAY_FACTORY) : ourRegistry; newRegistry[myIndex] = this; ourRegistry = newRegistry; } } else { myIndex = -1; } }
Example 3
Source File: HttpRequests.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public byte[] readBytes(@Nullable ProgressIndicator indicator) throws IOException { int contentLength = getConnection().getContentLength(); BufferExposingByteArrayOutputStream out = new BufferExposingByteArrayOutputStream(contentLength > 0 ? contentLength : BLOCK_SIZE); NetUtils.copyStreamContent(indicator, getInputStream(), out, contentLength); return ArrayUtil.realloc(out.getInternalBuffer(), out.size()); }
Example 4
Source File: StateMap.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static byte[] archiveState(@Nonnull Element state) { BufferExposingByteArrayOutputStream byteOut = new BufferExposingByteArrayOutputStream(); try { try (OutputStreamWriter writer = new OutputStreamWriter(new SnappyOutputStream(byteOut), CharsetToolkit.UTF8_CHARSET)) { XMLOutputter xmlOutputter = JDOMUtil.newXmlOutputter(); xmlOutputter.setFormat(XML_FORMAT); xmlOutputter.output(state, writer); } } catch (IOException e) { throw new StateStorageException(e); } return ArrayUtil.realloc(byteOut.getInternalBuffer(), byteOut.size()); }
Example 5
Source File: ShortBasedStorage.java From consulo with Apache License 2.0 | 5 votes |
@Override public void setData(int segmentIndex, int data) { if (segmentIndex >= myData.length) { myData = ArrayUtil.realloc(myData, calcCapacity(myData.length, segmentIndex)); } myData[segmentIndex] = (short)data; }
Example 6
Source File: ObjectStubTree.java From consulo with Apache License 2.0 | 5 votes |
@Override public void occurrence(@Nonnull final StubIndexKey indexKey, @Nonnull final Object value) { Map<Object, int[]> map = myResult.get(indexKey); if (map == null) { map = new THashMap<>((TObjectHashingStrategy<Object>)myHashingStrategyFunction.fun(indexKey)); myResult.put(indexKey, map); } int[] list = map.get(value); if (list == null) { map.put(value, new int[]{myStubIdx}); } else { int lastNonZero = ArrayUtil.lastIndexOfNot(list, 0); if (lastNonZero >= 0 && list[lastNonZero] == myStubIdx) { // second and subsequent occurrence calls for the same value are no op return; } int lastZero = lastNonZero + 1; if (lastZero == list.length) { list = ArrayUtil.realloc(list, Math.max(4, list.length << 1)); map.put(value, list); } list[lastZero] = myStubIdx; } }
Example 7
Source File: ObjectStubTree.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean execute(Object a, int[] b) { if (b.length == 1) return true; int firstZero = ArrayUtil.indexOf(b, 0); if (firstZero != -1) { int[] shorterList = ArrayUtil.realloc(b, firstZero); myProcessingMap.put(a, shorterList); } return true; }
Example 8
Source File: CommonsImagingImageReaderSpi.java From consulo with Apache License 2.0 | 5 votes |
@Override public byte[] getBlock(final int start, final int length) throws IOException { myStream.seek(start); final byte[] bytes = new byte[length]; final int read = myStream.read(bytes); return ArrayUtil.realloc(bytes, read); }
Example 9
Source File: CommonsImagingImageReaderSpi.java From consulo with Apache License 2.0 | 5 votes |
@Override public byte[] getBlock(final long start, final int length) throws IOException { myStream.seek(start); final byte[] bytes = new byte[length]; final int read = myStream.read(bytes); return ArrayUtil.realloc(bytes, read); }
Example 10
Source File: LayeredLexerEditorHighlighter.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static MappedRange[] reallocateArray(@Nonnull MappedRange[] array, int index) { if (index < array.length) return array; return ArrayUtil.realloc(array, SegmentArray.calcCapacity(array.length, index), MappedRange[]::new); }
Example 11
Source File: UnsignedShortArrayList.java From consulo with Apache License 2.0 | 4 votes |
public void trimToSize() { if (mySize < myData.length){ myData = ArrayUtil.realloc(myData, mySize); } }
Example 12
Source File: BooleanStack.java From consulo with Apache License 2.0 | 4 votes |
public void push(boolean t) { if (size >= data.length) { data = ArrayUtil.realloc(data, data.length * 3 / 2); } data[size++] = t; }
Example 13
Source File: CompressedAppendableFile.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static short[] reallocShortTable(short[] table) { return ArrayUtil.realloc(table, Math.max(table.length * 8 / 5, table.length + 1)); }
Example 14
Source File: SegmentArrayWithData.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull protected static int[] reallocateArray(@Nonnull int[] array, int index) { if (index < array.length) return array; return ArrayUtil.realloc(array, calcCapacity(array.length, index)); }
Example 15
Source File: ShortBasedStorage.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull protected static short[] reallocateArray(@Nonnull short[] array, int index) { if (index < array.length) return array; return ArrayUtil.realloc(array, calcCapacity(array.length, index)); }
Example 16
Source File: SegmentArray.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static int[] reallocateArray(@Nonnull int[] array, int index) { if (index < array.length) return array; return ArrayUtil.realloc(array, calcCapacity(array.length, index)); }