Collections

FloatList, IntList, and StringList — Processing-flavored typed lists, like Processing's own. Thin wrappers around List<T> with the handful of methods sketches actually reach for, rather than a 1:1 port of Java's much larger surface. Standalone value-holder types — like PVector, you just new FloatList() directly, no Sketch factory method needed.

On this page · 3 entries
What about FloatDict/IntDict/StringDict? Not ported, on purpose. A plain C# Dictionary<string, float> (or int/string) already does exactly what Processing's dict types do, with better performance and an API every C# developer already knows. That wrapper only earned its keep in Java, which didn't have comfortable generics when Processing's API was designed.

class FloatList · class IntList · class StringList

  • class FloatList
  • class IntList
  • class StringList

All three share the same shape — Size, an indexer (this[int]), and the methods below. FloatList/IntList additionally expose Min()/Max()/Sum() (and FloatList alone adds Average()) — numeric summaries that don't make sense for StringList, which instead adds Join(separator). All three implement IEnumerable<T>, so a plain foreach works too.

methoddoes
Append(value)Adds to the end.
Get(i) / Set(i, value)Read/write by index (same as the indexer).
Remove(i) / Clear()Removes one element, or everything.
Contains(value) / IndexOf(value)Linear search.
Sort() / SortReverse() / Reverse()In place.
Shuffle(Random? rng = null)Fisher-Yates in place. Uses its own internal Random by default — pass your own for reproducible results tied to a seed.
ToArray()Snapshot as a plain array.

IntList.Rangestatic

  • IntList.Range(int count) → IntList

Fills a new list with count sequential ints starting at 0 — handy for building an index list to shuffle/sort alongside parallel data.

C#
var heights = new FloatList();
for (int i = 0; i < 24; i++)
    heights.Append(Random(40, Height - 40));

heights.Shuffle();               // reorders in place
float avg = heights.Average();  // numeric summary

Runnable example

A complete sketch using this section. Test in Dana opens it in the IDE, or paste it into a new tab and press Run.

C#
// IntList, FloatList and StringList: Processing's handy lists.
public class Lists : Sketch
{
    IntList rolls = new IntList();
    StringList words = new StringList(new[] { "pear", "apple", "fig", "kiwi" });

    public override void Setup()
    {
        Size(520, 300);
        words.Sort();
    }

    public override void Draw()
    {
        Background(250);
        if (FrameCount % 10 == 0 && rolls.Size < 40)
rolls.Append((int)Random(1, 7));

        NoStroke();
        for (int i = 0; i < rolls.Size; i++)
        {
Fill(90, 140, 220);
Rect(20 + i * 12, 200 - rolls.Get(i) * 25, 10, rolls.Get(i) * 25);
        }
        Fill(30);
        if (rolls.Size > 0)
Text($"rolls {rolls.Size} · sum {rolls.Sum()} · max {rolls.Max()} · min {rolls.Min()}", 20, 230);
        Text("sorted: " + words.Join(", ") + " -- click to shuffle", 20, 260);
    }

    public override void MousePressed() => words.Shuffle();
}