Search in sources :

Example 1 with FastList

use of org.mvel2.util.FastList in project mvel by mikebrock.

the class InlineCollectionsPerformance method testJavaList.

public static void testJavaList() {
    FastList list;
    for (int i = 0; i < COUNT; i++) {
        list = new FastList(10);
        list.add("Foo244");
        list.add("Bar");
        list.add("Foo244");
        list.add("Bar");
        list.add("Foo244");
        list.add("Bar");
        list.add("Foo244");
        list.add("Bar");
        list.add("Foo244");
        list.add("Bar");
        assert "Foo244".equals(list.get(0)) && "Bar".equals(list.get(1)) && list.size() == 10;
    }
}
Also used : FastList(org.mvel2.util.FastList)

Example 2 with FastList

use of org.mvel2.util.FastList in project mvel by mikebrock.

the class UtilsTests method testAddAllFastList.

public void testAddAllFastList() throws Exception {
    FastList fl1 = new FastList(1);
    fl1.add("value1");
    fl1.add("value2");
    assertEquals(2, fl1.size());
    FastList fl2 = new FastList(1);
    fl2.add("value3");
    fl2.add("value4");
    // the addAll results in a list of 2 instead of 4 that was expected
    fl1.addAll(fl2);
    assertEquals(4, fl1.size());
}
Also used : FastList(org.mvel2.util.FastList)

Example 3 with FastList

use of org.mvel2.util.FastList in project mvel by mikebrock.

the class UtilsTests method testFastList1.

public void testFastList1() {
    FastList list = new FastList(3);
    list.add("One");
    list.add("Two");
    list.add("Three");
    list.add("Five");
    list.add(1, "Four");
    String[] zz1 = { "One", "Four", "Two", "Three", "Five" };
    int i = 0;
    for (Object o : list) {
        if (!zz1[i++].equals(o))
            throw new AssertionError("problem with list!");
    }
    list.remove(2);
    String[] zz2 = { "One", "Four", "Three", "Five" };
    i = 0;
    for (Object o : list) {
        if (!zz2[i++].equals(o))
            throw new AssertionError("problem with list!");
    }
}
Also used : FastList(org.mvel2.util.FastList)

Example 4 with FastList

use of org.mvel2.util.FastList in project mvel by mikebrock.

the class UtilsTests method testAddToFastList.

public void testAddToFastList() throws Exception {
    FastList fl = new FastList(0);
    assertEquals(0, fl.size());
    // this throws an ArrayIndexOutOfBoundsException:0
    fl.add("value");
    assertEquals(1, fl.size());
}
Also used : FastList(org.mvel2.util.FastList)

Aggregations

FastList (org.mvel2.util.FastList)4