com.artemis.utils.Bag.grow()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(97)

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

Bag.grow介绍

[英]Increase the capacity of the bag.
[中]增加袋子的容量。

代码示例

代码示例来源:origin: junkdog/artemis-odb

/**
 * Increase the capacity of the bag.
 *
 * @throws ArrayIndexOutOfBoundsException if new capacity is smaller than old
 */
@SuppressWarnings("unchecked")
private void grow() {
  grow(data.length * 2);
}

代码示例来源:origin: junkdog/artemis-odb

/**
 * Adds the specified element to the end of this bag.
 * <p>
 * If required, it also increases the capacity of the bag.
 * </p>
 *
 * @param e
 *            element to be added to this list
 */
public void add(E e) {
  // is size greater than capacity increase capacity
  if (size == data.length)
    grow(data.length * 2);
  data[size++] = e;
}

代码示例来源:origin: junkdog/artemis-odb

/**
 * Adds the specified element to the end of this bag.
 * <p>
 * If required, it also increases the capacity of the bag.
 * </p>
 * 
 * @param e
 *            element to be added to this list
 */
public void add(E e) {
  // is size greater than capacity increase capacity
  if (size == data.length)
    grow(data.length * 2);
  data[size++] = e;
}

代码示例来源:origin: junkdog/artemis-odb

/**
 * Check if an item, if added at the given item will fit into the bag.
 * <p>
 * If not, the bag capacity will be increased to hold an item at the index.
 * </p>
 *
 * <p>yeah, sorry, it's weird, but we don't want to change existing change behavior</p>
 *
 * @param index
 *            index to check
 */
public void ensureCapacity(int index) {
  if(index >= data.length) {
    grow(index + 1);
  }
}

代码示例来源:origin: junkdog/artemis-odb

/**
 * Check if an item, if added at the given item will fit into the bag.
 * <p>
 * If not, the bag capacity will be increased to hold an item at the index.
 * </p>
 *
 * <p>yeah, sorry, it's weird, but we don't want to change existing change behavior</p>
 *
 * @param index
 *            index to check
 */
public void ensureCapacity(int index) {
  if(index >= data.length) {
    grow(index + 1);
  }
}

代码示例来源:origin: net.onedaybeard.artemis/artemis-odb

/**
 * Adds the specified element to the end of this bag.
 * <p>
 * If required, it also increases the capacity of the bag.
 * </p>
 *
 * @param e
 *            element to be added to this list
 */
public void add(E e) {
  // is size greater than capacity increase capacity
  if (size == data.length)
    grow(data.length * 2);
  data[size++] = e;
}

代码示例来源:origin: net.onedaybeard.artemis/artemis-odb

/**
 * Check if an item, if added at the given item will fit into the bag.
 * <p>
 * If not, the bag capacity will be increased to hold an item at the index.
 * </p>
 *
 * <p>yeah, sorry, it's weird, but we don't want to change existing change behavior</p>
 *
 * @param index
 *            index to check
 */
public void ensureCapacity(int index) {
  if(index >= data.length) {
    grow(index + 1);
  }
}

代码示例来源:origin: junkdog/artemis-odb

/**
 * Returns the element at the specified position in Bag. This method
 * ensures that the bag grows if the requested index is outside the bounds
 * of the current backing array.
 * 
 * @param index
 *            index of the element to return
 *
 * @return the element at the specified position in bag
 *
 */
public E safeGet(int index) {
  if(index >= data.length)
    grow(Math.max((2 * data.length), (3 * index) / 2));
  return data[index];
}

代码示例来源:origin: junkdog/artemis-odb

/**
 * Returns the element at the specified position in Bag. This method
 * ensures that the bag grows if the requested index is outside the bounds
 * of the current backing array.
 *
 * @param index
 *            index of the element to return
 *
 * @return the element at the specified position in bag
 *
 */
public E safeGet(int index) {
  if(index >= data.length)
    grow(Math.max((2 * data.length), (3 * index) / 2));
  return data[index];
}

代码示例来源:origin: net.onedaybeard.artemis/artemis-odb

/**
 * Returns the element at the specified position in Bag. This method
 * ensures that the bag grows if the requested index is outside the bounds
 * of the current backing array.
 *
 * @param index
 *            index of the element to return
 *
 * @return the element at the specified position in bag
 *
 */
public E safeGet(int index) {
  if(index >= data.length)
    grow(Math.max((2 * data.length), (3 * index) / 2));
  return data[index];
}

代码示例来源:origin: junkdog/artemis-odb

/**
 * Set element at specified index in the bag.
 * 
 * @param index
 *            position of element
 * @param e
 *            the element
 */
public void set(int index, E e) {
  if(index >= data.length)
    grow(max((2 * data.length), index + 1));
  size = Math.max(size, index + 1);
  data[index] = e;
}

代码示例来源:origin: junkdog/artemis-odb

/**
 * Set element at specified index in the bag.
 *
 * @param index
 *            position of element
 * @param e
 *            the element
 */
public void set(int index, E e) {
  if(index >= data.length)
    grow(max((2 * data.length), index + 1));
  size = Math.max(size, index + 1);
  unsafeSet(index, e);
}

代码示例来源:origin: net.onedaybeard.artemis/artemis-odb

/**
 * Set element at specified index in the bag.
 *
 * @param index
 *            position of element
 * @param e
 *            the element
 */
public void set(int index, E e) {
  if(index >= data.length)
    grow(max((2 * data.length), index + 1));
  size = Math.max(size, index + 1);
  unsafeSet(index, e);
}

相关文章