[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: associative array

From: Francesco Potortì
Subject: Re: associative array
Date: Thu, 26 Mar 2020 23:01:51 +0100

>> Are there more efficient ways to build and update an associative array?

>What is the value associated with the key? How flexible you are?

The key is a numeric string, which I treat as a string.

>For numeric values, you can do this with 2 arrays (value and key, keys
>might be a string array), or 1 array and 1 cell.

The value is complex: it is a struct with four filds, two of which are
short arrays.

>The cost of operations in keys inherit the cost of string arrays or
>cells. The cost of operations in values inherit the costs of numeric

Finding an element in an array is fast only if the array is sorted, and
I do not know whether inserting into a sorted array would be faster than
adding a field to a struct.

>I would expect that struct are close to std::map in their complexity
>[1], N^2 would be pretty far away from that.

That's what made me wonder.  Maybe the cost of adding a new field is

Francesco Potortì (ricercatore)        Voice:  +39.050.621.3058
ISTI - Area della ricerca CNR          Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa         Skype:  wnlabisti
(gate 20, 1st floor, room C71)         Web:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]