Skip to content
Home » data structures

data structures

Wonderful List datatype in LotusScript

The general term for it is “associative array” — a collection of values indexed by a string rather than a numeric index. You might be thinking you already know about the List datatype in LotusScript, but there are a few tricks you might not have thought of. Basics Declare a variable of type List As datatype — for instance, Dim docsByColor List As NotesDocument Read and set values as you would an array, but using a string as your index value. Set docsByColor(doc.color(0)) = doc In this example we’re building an in-memory collection of documents that we can search by the value of their color field, so: Function getDocOfColor(ByVal color$) As NotesDocument If IsElement(docsByColor(color)) Then Set getDocOfColor = docsByColor(color) End If End Function Attempting to access an element with a key that’s not found in… Read More »Wonderful List datatype in LotusScript

LotusScript Stack data structure

The stack data structure is a collection of items that supports “last in, first out” access. You have two operations: “Push” an item onto the stack, and “Pop” to retrieve and remove the most recently added item. It’s like the stack of plates in a buffet restaurant, where unless you’re a rule-breaking savage, you can only take the plate on top, which was added last. Compare to a queue, where when you get a value from it, you’re getting the oldest thing it contains. A stack is used by the system to hold local variables and your position in the code when making multiple levels of calls in a program. Variables defined in the current module are at the top of the stack, then when you exit the module you “pop” that off, discarding it,… Read More »LotusScript Stack data structure

LotusScript Queue data structure

I previously wrote in general about data structures in LotusScript. Now I want to talk about one specific “classic” data structure, the queue. The strict version of this is like a pipeline where you put things in one end, and you pull them out the other end in the same order they went in. It’s a good way to keep track of work that needs doing. As with everything in LotusScript, as regards the datatype of the contents, you either have to write a generic class that can contain any type of data, or if you want type checking, specific classes for each content datatype you want to support. There’s no concept of an Interface like in Java, that you can just declare to the type you want. Specification The Queue class shown below can… Read More »LotusScript Queue data structure