![]() The driver code adds a series of strings whose lengths are in reverse alphabetical order, and we print the results of adding them to a Priority Queue object using our custom string length comparator (in which shorter strings come first), then the results of adding them to a normal Priority Queue object (which by default uses natural ordering, or lexicographical string ordering, alphabetical first). This implements a queue that adds the shortest Strings to the front of the queue. The simple example below uses a custom comparator when constructing a priority queue.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |