gpt4 book ai didi

org.geotools.resources.XArray.resize()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 00:31:05 27 4
gpt4 key购买 nike

本文整理了Java中org.geotools.resources.XArray.resize()方法的一些代码示例,展示了XArray.resize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XArray.resize()方法的具体详情如下:
包路径:org.geotools.resources.XArray
类名称:XArray
方法名:resize

XArray.resize介绍

[英]Returns a new table which contains the same elements as array but with the length specified. If the desired length is longer than the initial length of the array table, the returned table will contain all the elements of array as well as the elements initialised to null at the end of the table. If, on the contrary, the desired length is shorter than the initial length of the array table, the table will be truncated (that is to say the surplus array elements will be forgotten). If the length of array is equal to length, then array will be returned as it stands.
[中]返回一个新表,该表包含与数组相同的元素,但具有指定的长度。如果所需的长度大于数组表的初始长度,则返回的表将包含数组的所有元素以及在表末尾初始化为null的元素。相反,如果所需的长度小于数组表的初始长度,则该表将被截断(也就是说,多余的数组元素将被忽略)。如果数组的长度等于length,那么数组将按原样返回。

代码示例

代码示例来源:origin: org.geotools/gt2-coverageio

/**
 * Libre la mmoire rserve en trop. Cette mthode peut tre appele
 * lorsqu'on a termin de lire les donnes et qu'on veut les conserver
 * en mmoire pendant encore quelque temps.
 */
public void trimToSize() {
  if (data != null) {
    data = XArray.resize(data, upper);
  }
}

代码示例来源:origin: org.geotools/gt2-coverage

/**
 * Adds an observer. This observer will be notified everytime a tile initially empty become
 * available. If the observer is already present, it will receive multiple notifications.
 */
public synchronized void addTileObserver(final TileObserver observer) {
  if (observer != null) {
    if (observers == null) {
      observers = new TileObserver[] {observer};
    } else {
      final int length = observers.length;
      observers = (TileObserver[]) XArray.resize(observers, length+1);
      observers[length] = observer;
    }
  }
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Add the next element from the iterator to this set. This method doesn't check
 * if more element were available; the check must have been done before to invoke
 * this method.
 */
private void addNext() {
  if (size >= elements.length) {
    elements = XArray.resize(elements, size*2);
  }
  elements[size++] = iterator.next();
}

代码示例来源:origin: org.geotools/gt2-widgets-swing

/**
 * Makes sure that the {@link #visibles} array has the specified capacity.
 */
private void ensureCapacity(final int capacity) {
  if (visibles.length < capacity) {
    visibles = XArray.resize(visibles, Math.max(size*2, capacity));
  }
}

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Set all values in the current line. The {@code values} argument must be an array,
 * which may be of primitive type.
 *
 * @param  values The array to set as values.
 * @throws IllegalArgumentException if {@code values} is not an array.
 *
 * @since 2.4
 */
public void setValues(final Object values) throws IllegalArgumentException {
  final int length = Array.getLength(values);
  data = XArray.resize(data, length);
  for (int i=0; i<length; i++) {
    data[i] = Array.get(values, i);
  }
  count = length;
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Sets all values in the current line. The {@code values} argument must be an array,
 * which may be of primitive type.
 *
 * @param  values The array to set as values.
 * @throws IllegalArgumentException if {@code values} is not an array.
 *
 * @since 2.4
 */
public void setValues(final Object values) throws IllegalArgumentException {
  final int length = Array.getLength(values);
  data = XArray.resize(data, length);
  for (int i=0; i<length; i++) {
    data[i] = Array.get(values, i);
  }
  count = length;
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Trims the capacity of this list to be its current size.
 */
public void trimToSize() {
  values = XArray.resize(values, length(size));
}

代码示例来源:origin: org.geotools/gt2-coverageio

/**
 * Ajoute une ligne de donnes.  Si la ligne est plus courte que la longueur
 * attendues, les colonnes manquantes seront considres comme contenant des
 * {@code NaN}.   Si elle est plus longue que la longueur attendue, les
 * colonnes en trop seront ignores.
 */
public void add(final double[] line) {
  if (data==null) {
    if (columnCount<0) columnCount=line.length;
    min  = new double[columnCount]; Arrays.fill(min, Double.POSITIVE_INFINITY);
    max  = new double[columnCount]; Arrays.fill(max, Double.NEGATIVE_INFINITY);
    data = new float [columnCount*expectedLineCount];
  }
  final int limit=Math.min(columnCount, line.length);
  final int nextUpper = upper+columnCount;
  if (nextUpper >= data.length) {
    data = XArray.resize(data, Math.max(nextUpper, data.length+Math.min(data.length, 65536)));
  }
  for (int i=0; i<limit; i++) {
    final double value = line[i];
    if (value < min[i]) min[i] = value;
    if (value > max[i]) max[i] = value;
    data[upper+i] = (float)value;
  }
  Arrays.fill(data, upper+limit, nextUpper, Float.NaN);
  upper = nextUpper;
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Sets or adds a value to current line. The index should be in the range 0 to
 * {@link #getValueCount} inclusively. If the index is equals to {@link #getValueCount},
 * then {@code value} will be appended as a new column after existing data.
 *
 * @param  index Index of the value to add or modify.
 * @param  value The new value.
 * @throws ArrayIndexOutOfBoundsException If the index is outside the expected range.
 */
public void setValue(final int index, final Object value) throws ArrayIndexOutOfBoundsException {
  if (index > count) {
    throw new ArrayIndexOutOfBoundsException(index);
  }
  if (value == null) {
    throw new IllegalArgumentException(Errors.format(ErrorKeys.NULL_ARGUMENT_$1, "value"));
  }
  if (index == count) {
    if (index == data.length) {
      data = XArray.resize(data, index+Math.min(index, 256));
    }
    count++;
  }
  data[index] = value;
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Sets the list size to the given value. If the new size is lower than previous size,
 * then the elements after the new size are discarted. If the new size is greater than
 * the previous one, then the extra elements are initialized to 0.
 *
 * @param size The new size.
 */
public void resize(final int size) {
  if (size < 0) {
    throw new IllegalArgumentException();
  }
  if (size > this.size) {
    int base = this.size * bitCount;
    final int offset = base & OFFSET_MASK;
    base >>>= BASE_SHIFT;
    if (offset != 0 && base < values.length) {
      values[base] &= (1L << offset) - 1;
      base++;
    }
    final int length = length(size);
    Arrays.fill(values, base, Math.min(length, values.length), 0L);
    if (length > values.length) {
      values = XArray.resize(values, length);
    }
  }
  this.size = size;
}

代码示例来源:origin: org.geotools/gt2-widgets-swing

/**
 * Add the specified elements to the selection list (the one to appears on the right side). If
 * an element specified in the {@code selected} collection has not been previously {@linkplain
 * #addElements(Collection) added}, it will be ignored.
 *
 * @since 2.3
 */
public void selectElements(final Collection selected) {
  final Model source = (Model) left .getModel();
  final Model target = (Model) right.getModel();
  int[] indices = new int[Math.min(selected.size(), source.choices.size())];
  int indice=0, count=0;
  for (final Iterator it=source.choices.iterator(); it.hasNext(); indice++) {
    if (selected.contains(ListElement.unwrap(it.next()))) {
      indices[count++] = indice;
    }
  }
  indices = XArray.resize(indices, count);
  target.move(source, indices);
}

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Set or add a value to current line. The index should be in the range 0 to
 * {@link #getValueCount} inclusively. If the index is equals to {@link #getValueCount},
 * then {@code value} will be appended as a new column after existing data.
 *
 * @param  index Index of the value to add or modify.
 * @param  value The new value.
 * @throws ArrayIndexOutOfBoundsException If the index is outside the expected range.
 */
public void setValue(final int index, final Object value)
    throws ArrayIndexOutOfBoundsException
{
  if (index > count) {
    throw new ArrayIndexOutOfBoundsException(index);
  }
  if (value == null) {
    throw new IllegalArgumentException(Errors.format(ErrorKeys.NULL_ARGUMENT_$1, "value"));
  }
  if (index == count) {
    if (index == data.length) {
      data = XArray.resize(data, index+Math.min(index, 256));
    }
    count++;
  }
  data[index] = value;
}

代码示例来源:origin: org.geotools/gt2-widgets-swing

/**
 * Returns the array of kernel names. <strong>This method
 * returns the array by reference; do not modify!</strong>.
 *
 * @see KernelEditor#getKernelNames
 */
public String[] getKernelNames() {
  if (names == null) {
    int count = 0;
    names = new String[kernels.size() + 1];
    final String category = getKernelCategory();
    for (final Iterator it=categories.entrySet().iterator(); it.hasNext();) {
      final Map.Entry entry = (Map.Entry) it.next();
      if (category==null || category.equals(entry.getValue())) {
        names[count++] = (String) entry.getKey();
      }
    }
    names[count++] = getString(VocabularyKeys.PERSONALIZED);
    names = (String[]) XArray.resize(names, count);
  }
  return names;
}

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Returns the list of available locales.
 */
public static Locale[] getAvailableLocales() {
  final Locale[] languages = getAvailableLanguages();
  Locale[] locales = Locale.getAvailableLocales();
  int count = 0;
  for (int i=0; i<locales.length; i++) {
    final Locale locale = locales[i];
    if (containsLanguage(languages, locale)) {
      locales[count++] = locale;
    }
  }
  locales = (Locale[]) XArray.resize(locales, count);
  return locales;
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Returns the list of available locales.
 *
 * @return Available locales.
 */
public static Locale[] getAvailableLocales() {
  final Locale[] languages = getAvailableLanguages();
  Locale[] locales = Locale.getAvailableLocales();
  int count = 0;
  for (int i=0; i<locales.length; i++) {
    final Locale locale = locales[i];
    if (containsLanguage(languages, locale)) {
      locales[count++] = locale;
    }
  }
  locales = XArray.resize(locales, count);
  return locales;
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Returns a view of this set as an array. Elements will be in an arbitrary
 * order. Note that this array contains strong reference.  Consequently, no
 * object reclamation will occurs as long as a reference to this array is hold.
 */
@Override
public synchronized E[] toArray() {
  assert valid();
  @SuppressWarnings("unchecked")
  final E[] elements = (E[]) Array.newInstance(type, count);
  int index = 0;
  for (int i=0; i<table.length; i++) {
    for (Entry el=table[i]; el!=null; el=el.next) {
      if ((elements[index]=el.get()) != null) {
        index++;
      }
    }
  }
  return XArray.resize(elements, index);
}

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Returns a view of this set as an array. Elements will be in an arbitrary
 * order. Note that this array contains strong reference.  Consequently, no
 * object reclamation will occurs as long as a reference to this array is hold.
 */
public synchronized Object[] toArray() {
  assert valid();
  final Object[] elements = new Object[count];
  int index = 0;
  for (int i=0; i<table.length; i++) {
    for (Entry el=table[i]; el!=null; el=el.next) {
      if ((elements[index]=el.get()) != null) {
        index++;
      }
    }
  }
  return XArray.resize(elements, index);
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Returns the list of unprocessed arguments. If the number of remaining arguments is
 * greater than the specified maximum, then this method invokes {@link #illegalArgument}.
 *
 * @param  max Maximum remaining arguments autorized.
 * @return An array of remaining arguments. Will never be longer than {@code max}.
 */
public String[] getRemainingArguments(final int max) {
  int count = 0;
  final String[] left = new String[Math.min(max, arguments.length)];
  for (int i=0; i<arguments.length; i++) {
    final String arg = arguments[i];
    if (arg != null) {
      if (count >= max) {
        illegalArgument(new IllegalArgumentException(Errors.getResources(locale).
                getString(ErrorKeys.UNEXPECTED_PARAMETER_$1, arguments[i])));
      }
      left[count++] = arg;
    }
  }
  return XArray.resize(left, count);
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Adds the given element as the {@code int} primitive type.
 *
 * @param value The value to add.
 * @throws IllegalArgumentException if the given value is out of bounds.
 */
public void addInteger(final int value) throws IllegalArgumentException {
  if (value < 0 || value > mask) {
    throw new IllegalArgumentException(Errors.format(ErrorKeys.VALUE_OUT_OF_BOUNDS_$3,
        value, 0, mask));
  }
  final int length = length(++size);
  if (length > values.length) {
    values = XArray.resize(values, 2*values.length);
  }
  setUnchecked(size - 1, value);
}

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Returns the list of unprocessed arguments. If the number of remaining arguments is
 * greater than the specified maximum, then this method invokes {@link #illegalArgument}.
 *
 * @param  max Maximum remaining arguments autorized.
 * @return An array of remaining arguments. Will never be longer than {@code max}.
 */
public String[] getRemainingArguments(final int max) {
  int count = 0;
  final String[] left = new String[Math.min(max, arguments.length)];
  for (int i=0; i<arguments.length; i++) {
    final String arg = arguments[i];
    if (arg != null) {
      if (count >= max) {
        illegalArgument(new IllegalArgumentException(Errors.getResources(locale).
                format(ErrorKeys.UNEXPECTED_PARAMETER_$1, arguments[i])));
      }
      left[count++] = arg;
    }
  }
  return (String[]) XArray.resize(left, count);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com