@Alfred.NESWADBA wrote:
Hi,
>> Additionally, a collection is not a logical set, and it doesn't restrict you
>> from adding multiple elements that are equal
Ever tried to add one (the same) ObjectID twice to a ObjectIsCollection-object?
ObjectIdCollection is a managed wrapper around the native AcDbObjectIdArray, which is in-turn a wrapper around a C++ array. I've been using the native AcDbObjectIdArray since AutoCAD R13 was current (and it's managed wrapper since the first .NET API was released in AutoCAD 2006), and I can assure you that it will allow you to add the same ObjectId multiple times.
>> An array is not resizable
And what does that:
Dim X(1) as ObjectID
Redim Preserve X(2)
???
It creates a completely new array of the specified size, and then it copies the elements from the existing array to the new array, and replaces any references to the existing array with references to the new array. That's also why legacy VB programs that use redim preserve each time a new item is added an existing array, can be so pathically slow.
That is not by-definition, 'resizing', but in the context of this topic, what I meant by 'resizeable' was that an array is not dynamically resizable with methods to add/remove elements without having to contend with the underlying details of what must happen when additional memory is needed. In reality, because a List<T> is just a wrapper around an array, it must do the same thing that redim preserve does, except that it is handled internally and hidden from the programmer, and it also doesn't have to be done each time another item is added (when additional capacity is required by the internal array, a new array is created whose size is double the size of the existing array, and the existing elements are copied to it). But, because capacity increases expontially, there is no need for to re-allocate memory for a new array and copy the data there, every time an element is added.