Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Từ điển là một cấu trúc dữ liệu lưu trữ dữ liệu như là một cặp khoá-giá trị. các DictionaryBase lớp được sử dụng như một lớp trừu tượng để thực hiện các cấu trúc dữ liệu khác nhau mà tất cả các lưu trữ dữ liệu như cặp giá trị key-. Những cấu trúc dữ liệu có thể được các bảng băm, danh sách liên kết | Chapter 9 Building Dictionaries The DictionaryBase Class and the SortedList Class A dictionary is a data structure that stores data as a key-value pair. The DictionaryBase class is used as an abstract class to implement different data structures that all store data as key-value pairs. These data structures can be hash tables linked lists or some other data structure type. In this chapter we examine how to create basic dictionaries and how to use the inherited methods of the DictionaryBase class. We will use these techniques later when we explore more specialized data structures. One example of a dictionary-based data structure is the SortedList. This class stores key-value pairs in sorted order based on the key. It is an interesting data structure because you can also access the values stored in the structure by referring to the value s index position in the data structure which makes the structure behave somewhat like an array. We examine the behavior of the SortedList class at the end of the chapter. 200 The DictionaryBase Class 201 The Dictionarybase Class You can think of a dictionary data structure as a computerized word dictionary. The word you are looking up is the key and the definition of the word is the value. The DictionaryBase class is an abstract MustInherit class that is used as a basis for specialized dictionary implementations. The key-value pairs stored in a dictionary are actually stored as DictionaryEntry objects. The DictionaryEntry structure provides two fields one for the key and one for the value. The only two properties or methods we re interested in with this structure are the Key and Value properties. These methods return the values stored when a key-value pair is entered into a dictionary. We explore DictionaryEntry objects later in the chapter. Internally key-value pairs are stored in a hash table object called Inner-HashTable. We discuss hash tables in more detail in Chapter 12 so for now just view it as an efficient data structure for