![]() ![]() Reducing the mutability of objects is a best practice. What does that mean? Once you initialize an instance of a map, you can’t change it anymore. Interestingly, the standard interface for maps in Kotlin is immutable. However, you should know that most default constructors create hash tables ( LinkedHashMap in Java, for example). Typically, you’ll use a hash table unless you need to iterate over the keys in order.įor this article, the implementation isn’t relevant because the interface doesn’t change. However, it keeps the keys sorted according to their natural order. The performance isn’t as good as hash tables. Search tree: It uses a tree structure to store the keys.The performance is linear as long as the hash function distributes keys uniformly. The pairs go in an array of buckets based on that index. Hash tables: It uses a hash function to compute an index for every key.There are two main implementations of maps: An implementation of a data type is a data structure. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |