Example usage for java.util ArrayList set

List of usage examples for java.util ArrayList set

Introduction

In this page you can find the example usage for java.util ArrayList set.

Prototype

public E set(int index, E element) 

Source Link

Document

Replaces the element at the specified position in this list with the specified element.

Usage

From source file:Windows.UI.Xaml.Controls.Handle.java

void assign(Object instance, java.util.ArrayList<Object> list) {
    if (list.size() == this.value) {
        list.add(instance);// w w  w  .j av a  2 s .  c  o  m
    } else if (list.size() > this.value) {
        list.set(this.value, instance);
    } else {
        // Just fill with nulls up to this point.
        // This would have been caused by an earlier instantiation exception,
        // but cascading errors simply from unexpected handles are annoying.
        while (list.size() < this.value) {
            list.add(null);
        }
        list.add(instance);
    }
}

From source file:parquet.hive.serde.ArrayWritableObjectInspector.java

@Override
public Object setStructFieldData(Object struct, StructField field, Object fieldValue) {
    final ArrayList<Object> list = (ArrayList<Object>) struct;
    list.set(((StructFieldImpl) field).getIndex(), fieldValue);
    return list;//from  ww  w . j a  v  a2s .  c o m
}

From source file:org.apache.kylin.common.util.BasicTest.java

@Test
@Ignore("fix it later")
public void test2() throws IOException {
    ArrayList<String> x = Lists.newArrayListWithCapacity(10);
    x.set(2, "dd");
    for (String y : x) {
        System.out.println(y);// w  w  w.ja va 2s . c  o  m
    }
}

From source file:org.apache.hadoop.hive.ql.exec.persistence.MapJoinBytesTableContainer.java

public static List<Object> getComplexFieldsAsList(LazyBinaryStruct lazyBinaryStruct,
        ArrayList<Object> objectArrayBuffer, LazyBinaryStructObjectInspector lazyBinaryStructObjectInspector) {

    List<? extends StructField> fields = lazyBinaryStructObjectInspector.getAllStructFieldRefs();
    for (int i = 0; i < fields.size(); i++) {
        StructField field = fields.get(i);
        ObjectInspector objectInspector = field.getFieldObjectInspector();
        Category category = objectInspector.getCategory();
        Object object = lazyBinaryStruct.getField(i);
        if (category == Category.PRIMITIVE) {
            objectArrayBuffer.set(i, object);
        } else {/*from  w  ww.ja  va2  s  .c o m*/
            objectArrayBuffer.set(i, ObjectInspectorUtils.copyToStandardObject(object, objectInspector,
                    ObjectInspectorCopyOption.WRITABLE));
        }
    }
    return objectArrayBuffer;
}

From source file:co.cask.cdap.hive.objectinspector.StandardStructObjectInspector.java

@Override
public Object setStructFieldData(Object struct, StructField field, Object fieldValue) {
    ArrayList<Object> a = (ArrayList<Object>) struct;
    MyField myField = (MyField) field;/*  ww  w . j  av  a  2  s  . co  m*/
    a.set(myField.fieldID, fieldValue);
    return a;
}

From source file:org.cloudfoundry.identity.uaa.user.UaaUser.java

public UaaUser authorities(Collection<? extends GrantedAuthority> authorities) {
    ArrayList<GrantedAuthority> values = new ArrayList<GrantedAuthority>(authorities);
    for (int i = 0; i < values.size(); i++) {
        GrantedAuthority authority = values.get(i);
        values.set(i, UaaAuthority.authority(authority.toString()));
    }//from   w w w  . j  av a 2  s  .  co m
    if (!values.contains(UaaAuthority.UAA_USER)) {
        values.add(UaaAuthority.UAA_USER);
    }
    UaaUser user = new UaaUser(id, username, password, email, values, givenName, familyName, created, modified);
    return user;
}

From source file:kr.ac.kaist.se.simulator.NormalDistributor.java

public ArrayList<Integer> getDistributionArray(int numOfSamples) {
    ArrayList<Integer> retList = new ArrayList<>();
    for (int i = 0; i < numOfSamples; i++)
        retList.add(this.getNextVal());
    Collections.sort(retList);/*from w  w  w  .  j av  a  2 s .c om*/
    for (int i = 0; i < retList.size(); i++) {
        if (retList.get(i) < 0)
            retList.set(i, 0);
    }
    return retList;
}

From source file:org.signserver.client.cli.performance.PerformanceTestPDFServlet.java

License:asdf

/** @see org.signserver.client.PerformanceTestTask */
public void createDiagrams(String currentFileName, String statisticsDirectory, ArrayList<String> explanationRow,
        ArrayList<ArrayList<Double>> processedData) {
    explanationRow.set(COLUMN_DATAFLOW, "Data throughput (bytes/second)"); // Set nicer explanation

    if (!statisticsDirectory.endsWith("/")) {
        statisticsDirectory += "/";
    }//from   ww  w  .  j ava2  s  .c om
    // Diagram: X: Avg PDF Size Y1: Invocations/second Y2: PDF data/second
    createDiagram(statisticsDirectory, explanationRow, processedData, COLUMN_AVERAGE_PDF_SIZE,
            COLUMN_INVOCATIONS_PER_SECOND, COLUMN_DATAFLOW);
    // Diagram: X: Time Y1: Invocations/second Y2: PDF average size
    createDiagram(statisticsDirectory, explanationRow, processedData, COLUMN_TIME,
            COLUMN_INVOCATIONS_PER_SECOND, COLUMN_AVERAGE_PDF_SIZE);
    // Diagram: X: Time Y1: PDF average size Y2: Data flow
    createDiagram(statisticsDirectory, explanationRow, processedData, COLUMN_TIME, COLUMN_AVERAGE_PDF_SIZE,
            COLUMN_DATAFLOW);
}

From source file:com.example.oris1991.anotherme.ExternalCalendar.CalendarAdapter.java

public void setItems(ArrayList<String> items) {
    for (int i = 0; i != items.size(); i++) {
        if (items.get(i).length() == 1) {
            items.set(i, "0" + items.get(i));
        }/*from  w ww .j a  v  a 2  s .c o m*/
    }
    this.items = items;
}

From source file:org.pooledtimeseries.PoT.java

public static void normalizeFeatureL1(ArrayList<Double> sample) {
    int sum = 0;/*from www .  ja  v a  2s .  c  o  m*/

    for (int i = 0; i < sample.size(); i++) {
        double val = sample.get(i);
        if (val < 0)
            val = -1 * val;

        sum += val;
    }

    for (int i = 0; i < sample.size(); i++) {
        double v;
        if (sum == 0)
            v = 0;
        else
            v = sample.get(i) / sum;// *100;

        sample.set(i, v);
    }
}