Mentioned in the last post, the use count vector member was removed and a use count was put into the value of the map. A new private Entry Value structure was created to hold the index and the use count of the entry. Both were defined as unsigned 16-bit integers. A constructor was added taking a single index argument and the use count is initialized to 1.
For the add function, the entry in the use count vector no longer needs to be added or initialized (in the case of a reused entry). Instead of assigning a key to an index using the bracket operator, the map emplace function is used with a single index. The use count get set to 1 whether it is a new or a reused entry by the constructor of the Entry Value structure. For an existing entry, the iterator is used to increment the use count.
For the remove function, since the use count is no longer available by index, the index is used to get the key from the key list member. The key is converted to upper case for case insensitive dictionaries and used to find an iterator for the key. While the index is available in the iterator, it is used to clear the entry in the key list and pushed to the free stack. The iterator is used to erase the entry from the key map (entries can be erased either by key value or iterator).
For the debug text function, since the use count is no longer available by index, a non-empty entry in the key list is used to identify if an entry is used. The key is used to find an iterator to the entry. An error check was added if the key was not found (shouldn't happen). The iterator is used to get the use count. When outputting the indexes of the free stack, the check for a non-zero use count was removed since the use count is no longer available (the entry in the map with the use count was erased, and an entry is not pushed to the free stack unless the use count was zero).
[branch stl commit e79c179ad5]
Saturday, October 4, 2014
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)