类 IntArray


  • public class IntArray
    extends java.lang.Object
    A dynamic array that uses int not Integer objects. In principle this is more efficient in time, but certainly in space. This is simple enough that you can access the data array directly, but make sure that you append elements only with add() so that you get dynamic sizing. Make sure to call ensureCapacity() when you are manually adding new elements. Doesn't impl List because it doesn't return objects and I mean this really as just an array not a List per se. Manipulate the elements at will. This has stack methods too. When runtime can be 1.5, I'll make this generic.
    • 字段概要

      字段 
      修饰符和类型 字段 说明
      int[] data  
      static int INITIAL_SIZE  
      protected int p  
    • 构造器概要

      构造器 
      构造器 说明
      IntArray()  
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      void add​(int v)  
      void clear()  
      void ensureCapacity​(int index)  
      int pop()  
      void push​(int v)  
      int size()
      This only tracks elements added via push/add.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • INITIAL_SIZE

        public static final int INITIAL_SIZE
        另请参阅:
        常量字段值
      • data

        public int[] data
      • p

        protected int p
    • 构造器详细资料

      • IntArray

        public IntArray()
    • 方法详细资料

      • add

        public void add​(int v)
      • push

        public void push​(int v)
      • pop

        public int pop()
      • size

        public int size()
        This only tracks elements added via push/add.
      • clear

        public void clear()
      • ensureCapacity

        public void ensureCapacity​(int index)