For high-performance, array-backed data structures are generally recommended. On the other hand, inserting into a large array isn't the fastest thing. BListJid uses small arrays (max size is 27) in a balanced tree structure to support fast updates and super fast incremental deserialization/reserialization.

As with other Jid classes, a registered factory object is mandatory. The JidFactories class registers 8 different types of BListJid, one of which is a list of integers.

The iAdd method creates an inserts a new Jid object at a given location, where 0 is the first location, 1 is the second, -1 is the last location, -2 is the next-to-last location, etc.

BListJid supports only homogenous lists, where all the entries are of the same class. The advantage is that the serialized data is smaller than it would otherwise be and performance is a bit better as well. But sometimes we need a list of homogenous objects. This can be achieved with ActorJid, which is a superclass of RootJid and which can hold any object that subclasses Jid.

Being able to constrain the types used in a data structure can be important, and this is one of the advantages of using UnionJid instead of ActorJid. It also results in serialized data that is a bit more compact and a bit faster to deserialize. It also supports recursive types, which is what we will be looking at in this next example.

In the above code we define the type union1, which can hold either a StringJid or a Jid of type unions. And the type unions is defined as a BListJid whose elements are of type union1. We then proceed to create a list whose first element is a StringJid with a value of "a" and whose second element is a list whose first element is a StringJid with a value of "b".