A set of integers. Possible performance improvement in the case of an increase in the number of new records

If you were a highly skilled Java developer with a low latency (I didn’t), and you were told to implement the int set (primitive or not), is it possible to get additional profit from the performance provided guaranteed Let us assume that each new record is higher than any other value previously stored in recruitment?

How significant can the gain be for operations add, containsand removein best / worst case scenarios?

On the one hand, it seems natural that such a limitation will lead to increased productivity. On the other hand, non-decreasing entries are a very common situation (for example, when generating a unique identifier), and if the gain is worth fighting, then a more or less well-known implementation would have already been developed.

+4
source share
1 answer

When you check this question , you will find that addit is containsalready O (1). Thus, there are not many improvements.

And I think that these two would be the only ones who could use this restriction:

  • "" , ;
  • , ""; , ,

.

: , , , , , ​​ . , . ...

, O (1) O (1.5); :

O (1) O (n) , , . O (1.0) O (1.005)... .

: "" , "" . , , , ; JVM . , , .

; , . , ; : . : ; ; .

; " " ( , ). real (, , ) .

+3

Source: https://habr.com/ru/post/1670285/


All Articles