Package java.util

Examples of java.util.ArrayList.ensureCapacity()


        if (index < 0)
        {
          throw new ParseException("Failed to parse array index", getLocator());
        }
       
        list.ensureCapacity(index);
        while (list.size() < (index + 1))
        {
          list.add(null);
        }
        list.set(index, ObjectConverterFactory.convert(componentType, value, getLocator()));
View Full Code Here


    }

    ArrayList currentParameters = (ArrayList)parameters.get(parameters.size()-1);
    if ( currentParameters!=null) {
      if ( currentParameters.size()<=paramIndex) {
        currentParameters.ensureCapacity(paramIndex+1);
        for ( int i = currentParameters.size(); i < paramIndex; i++) currentParameters.add(i,null);
          currentParameters.add(paramIndex,parameter);
      } else {
        currentParameters.set(paramIndex,parameter);
      }
View Full Code Here

      List<Attribute> list = attributeList();

      if (list instanceof ArrayList) {
        ArrayList arrayList = (ArrayList) list;

        arrayList.ensureCapacity(minCapacity);
      }
    }
  }

  // Implementation methods
View Full Code Here

    if ( reader == null ) return null;
    ArrayList result = new ArrayList();
    try {
      char[] charbuf = new char[BUFFER_SIZE];
      for ( int i = reader.read( charbuf ); i > 0 ; i = reader.read( charbuf ) ) {
        result.ensureCapacity( result.size() + BUFFER_SIZE );
        for ( int charIndex = 0; charIndex < i ; charIndex++ ) {
          result.add( Character.valueOf( charbuf[charIndex] ) );
        }
      }
    }
View Full Code Here

    public void ensureCapacity(int capacity) {

        if (fast) {
            synchronized (this) {
                ArrayList temp = (ArrayList) list.clone();
                temp.ensureCapacity(capacity);
                list = temp;
            }
        } else {
            synchronized (list) {
                list.ensureCapacity(capacity);
View Full Code Here

    if ( reader == null ) return null;
    ArrayList result = new ArrayList();
    try {
      char[] charbuf = new char[BUFFER_SIZE];
      for ( int i = reader.read( charbuf ); i > 0 ; i = reader.read( charbuf ) ) {
        result.ensureCapacity( result.size() + BUFFER_SIZE );
        for ( int charIndex = 0; charIndex < i ; charIndex++ ) {
          result.add( Character.valueOf( charbuf[charIndex] ) );
        }
      }
    }
View Full Code Here

        for (i = 0; i < capacity / 2; i++) {
            al.add(i, new Object());
        }
        al.add(i, testObject);
        int location = al.indexOf(testObject);
        al.ensureCapacity(capacity);
        assertTrue("EnsureCapacity moved objects around in array1.",
                location == al.indexOf(testObject));
        al.remove(0);
        al.ensureCapacity(capacity);
        assertTrue("EnsureCapacity moved objects around in array2.",
View Full Code Here

        int location = al.indexOf(testObject);
        al.ensureCapacity(capacity);
        assertTrue("EnsureCapacity moved objects around in array1.",
                location == al.indexOf(testObject));
        al.remove(0);
        al.ensureCapacity(capacity);
        assertTrue("EnsureCapacity moved objects around in array2.",
                --location == al.indexOf(testObject));
        al.ensureCapacity(capacity + 2);
        assertTrue("EnsureCapacity did not change location.", location == al
                .indexOf(testObject));
View Full Code Here

                location == al.indexOf(testObject));
        al.remove(0);
        al.ensureCapacity(capacity);
        assertTrue("EnsureCapacity moved objects around in array2.",
                --location == al.indexOf(testObject));
        al.ensureCapacity(capacity + 2);
        assertTrue("EnsureCapacity did not change location.", location == al
                .indexOf(testObject));
    }

    /**
 
View Full Code Here

      al.add(i, new Object());
    }
    al.add(i, testObject);
    int location = al.indexOf(testObject);
    try {
      al.ensureCapacity(capacity);
      assertTrue("EnsureCapacity moved objects around in array1.",
          location == al.indexOf(testObject));
      al.remove(0);
      al.ensureCapacity(capacity);
      assertTrue("EnsureCapacity moved objects around in array2.",
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.