What fundamental data structure is used to implement NSOrderedSet

Smart Home

NSOrderedSet seems to be able to give O(1) lookup speed of hash-tables and array like ordering of objects? What is the data structure used to achieve this? Is it a combination of two, e.g: Hashtable and a separate Array where index i has the key corresponding to it's object in the Hashtable?

Sven

We don't know how Apple chose to implement this data structure. The only way to find out would be to reverse-engineer the Foundation framework. But this is not an useful thing to do, Apple could change the implementation and underlying data structure with every update. So relying on this for a production app would be very stupid since it could break the app at any time.

If you wanted to implement this yourself your approach with a hash table and an array will work. The best way would be to store the objects in the array and have the hash map store the array indices keyed by objects.

Of course there are other possible ways how this could be implemented with different performance characteristics. It could be just an array making the containsObject: test O(n), or it could just be a hash table (with the object as key and index as value) making the objectAtIndex: operation O(n).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

What is the best data structure to implement a queue?

From Dev

What data structure is used in apps for modifiable lists?

From Dev

What are the data structures used to implement the Process Control Block in Unix?

From Java

What data structure could be used to store objects with multiple comparable attributes

From Dev

What's the most-used data structure in OCaml to represent a Graph?

From Dev

What kind of data structure is used by the SQLite in-memory database?

From Dev

What is the data structure typically used to map input to the display?

From Dev

What's the most-used data structure in OCaml to represent a Graph?

From Dev

What is the best data structure to implement a 2D Matrix with String data type?

From Dev

Suggest Data Structure which implement this

From Java

What is a "fundamental type" in Rust?

From Dev

What data structure do I need or how to implement a "LIFO-like" queue?

From Dev

What's the best way to implement update deeply nested JSON structure with Spring Data REST?

From Dev

What type of structure is this data?

From Dev

What is the name of this data structure?

From Dev

What is the data structure of $@ in shell?

From Dev

What type of structure is this data?

From Dev

What is the name of this data structure?

From Dev

What is a Plex data structure?

From Dev

What Abstract Data Type (ADT) is used to implement steinhaus-johnson-trotter (permutations) algorithm in Python?

From Java

What is the best C++ data structure that could be used for storing and managing a collection of integers?

From Dev

What Data Structure should be used to store a large sentence (may be millions of words) with repetition of words

From Dev

What algorithm is used to implement HermiteH function (mathematica)

From Dev

What algorithm is used to implement HermiteH function (mathematica)

From Dev

What kind of normalization is used here in database structure?

From Dev

Hibernate how to implement dynamic data structure

From Dev

How to implement a Set Data Structure in Java?

From Dev

Which data structure is most suitable to implement a Dictionary?

From Dev

Best data structure to implement the APIs for Game Scoreboard

Related Related

  1. 1

    What is the best data structure to implement a queue?

  2. 2

    What data structure is used in apps for modifiable lists?

  3. 3

    What are the data structures used to implement the Process Control Block in Unix?

  4. 4

    What data structure could be used to store objects with multiple comparable attributes

  5. 5

    What's the most-used data structure in OCaml to represent a Graph?

  6. 6

    What kind of data structure is used by the SQLite in-memory database?

  7. 7

    What is the data structure typically used to map input to the display?

  8. 8

    What's the most-used data structure in OCaml to represent a Graph?

  9. 9

    What is the best data structure to implement a 2D Matrix with String data type?

  10. 10

    Suggest Data Structure which implement this

  11. 11

    What is a "fundamental type" in Rust?

  12. 12

    What data structure do I need or how to implement a "LIFO-like" queue?

  13. 13

    What's the best way to implement update deeply nested JSON structure with Spring Data REST?

  14. 14

    What type of structure is this data?

  15. 15

    What is the name of this data structure?

  16. 16

    What is the data structure of $@ in shell?

  17. 17

    What type of structure is this data?

  18. 18

    What is the name of this data structure?

  19. 19

    What is a Plex data structure?

  20. 20

    What Abstract Data Type (ADT) is used to implement steinhaus-johnson-trotter (permutations) algorithm in Python?

  21. 21

    What is the best C++ data structure that could be used for storing and managing a collection of integers?

  22. 22

    What Data Structure should be used to store a large sentence (may be millions of words) with repetition of words

  23. 23

    What algorithm is used to implement HermiteH function (mathematica)

  24. 24

    What algorithm is used to implement HermiteH function (mathematica)

  25. 25

    What kind of normalization is used here in database structure?

  26. 26

    Hibernate how to implement dynamic data structure

  27. 27

    How to implement a Set Data Structure in Java?

  28. 28

    Which data structure is most suitable to implement a Dictionary?

  29. 29

    Best data structure to implement the APIs for Game Scoreboard

HotTag

Archive