Item Arrives on Order

The order algorithm is slightly more complex because the on hand list is a list of widgets, not widget numbers. Thus, to search it we need a function that will compare a widget and a given widget number. There is no such function already in the library, so we build it, as shown on the next slide.

Having build a widget comparison function, we can use the find_if generic algorithm, an algorithm that takes a function object and returns the first value that satisfies the function.

If find_if returns value, it means we have it on hand and can ship immediately. Otherwise it gets back ordered, and added to the back order list.

[audio] [real] Text to accompany slide14, in Chapter 16 of An Introduction to Object-Oriented Programming