[Gambas-user] Sparse arrays? Possible?
Bruce
adamnt42 at gmail.com
Mon Mar 9 02:30:34 CET 2020
Thanks Jussi,
I think I will go that way.
b
p.s. You don't want to see this code. In fact I don't like looking at
it. It grew without enough thought and incomplete requirements.
:-(
b
On 9/3/20 11:54 am, Jussi Lahtinen wrote:
> There rarely are good answers to questions like that without seeing the
> code. But it seems I would use the normal dynamic object arrays.
> Dim hArr As New Object[]
>
> Fill the array with null objects up to known biggest value.
> hArr.Insert(hTempArr.Resize(iBiggestValue))
>
> And then just add the object. Unless the value is already within the max
> index, then just add.
>
>
> Jussi
>
>
> On Mon, Mar 9, 2020 at 12:38 AM Bruce <adamnt42 at gmail.com
> <mailto:adamnt42 at gmail.com>> wrote:
>
> Much existing code uses the (full) array. The sparse situation occurs
> perhaps <5% of the time and represents "changes" to the existing set
> already present in the full array. I suppose that I could detect that
> the incoming messages represent changes and handle that as a temporary
> collection but then I'd have to clone and modify many methods that
> already exist in both applications and libraries (with the concomitant
> danger to both the current development and the ongoning support...
>
> The damn problem is that I cant process the change messages one by one,
> the entire set of original objects is affected by the entire set of
> changes. And the changes must be done in an atomic sense because while
> one change set is building another (different) change set may start to
> arrive. Grrrr.
> b
>
> On 9/3/20 5:06 am, Jussi Lahtinen wrote:
> > Can you open bit more why using collection is out of the question?
> >
> > Jussi
> >
> > On Sun, Mar 8, 2020 at 7:16 AM Bruce <adamnt42 at gmail.com
> <mailto:adamnt42 at gmail.com>
> > <mailto:adamnt42 at gmail.com <mailto:adamnt42 at gmail.com>>> wrote:
> >
> > Firstly, I haven't tried this but I was wondering if it is
> possible.
> >
> > Given a set of objects that have an ordinal characteristic (not a
> > property of the object itself and not encountered in the
> ascending
> > order
> > of that characteristic) is it possible to construct an array
> of such
> > objects that is only sparsely populated?
> >
> > Let's say we have the following objects, with that derived
> > characteristic in brackets: Ahab(3),Chab(6), Fhab(2) and Ghab(7).
> > I want to fill the array such that its' final representation is
> > [0] -
> > [1] -
> > [2] Fhab
> > [3] Ahab
> > [4] -
> > [5] -
> > [6] Chab
> > [7] Ghab
> >
> > I don't know at the outset what the maximum ordinal value is
> and so I
> > don't know the size of the array.
> > There are reasons for using an array rather than a collection
> keyed by
> > the value.
> > The source of the objects is unsortable, they arrive over
> time in a
> > random order.
> >
> > Any thoughts?
> > b
> >
> > p.s. It's like the IP layer in TCP/IP putting the packets
> back in order
> > to rebuild the entire message.
> >
> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> >
> >
> >
> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> >
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
More information about the User
mailing list