I think I've found the cause. It's really bad practice to call 'find with...' function for associative array. A benchmark of locator method for various vectors, like dynamic array, associative array and queue, tells that the performance would drop tremendously if the 'find with...' method was applied on associative array. Admittedly, if we locate the associative array through its index directly, it behaves as expected. Though it's not likely to locate the associative array through 'find with...' method instead of its intuitive index, there's chance when users have to apply some complex expression to 'find with...' method, e.g, a_array.find with (item.addr >= MIN; item.addr <= MAX; item.attr == 1;...) , where as a result the performance might heavily be impacted. In this case, it's embarrassed when user initially takes advantage of associative array for efficient locating and some time later, he/she somehow has to apply 'find with...' method on the associative array as well. Do you have any suggestion on how to balance the pros and cons of associative array?
↧