void active_item_cache::add( std::list<item>::iterator it, point location )
{
    if( has( it, location ) ) {
        return;
    }
    active_items[it->processing_speed()].push_back( item_reference{ location, it, &*it } );
    active_item_set[ &*it ] = false;
}
void active_item_cache::remove( std::list<item>::iterator it, point location )
{
    const auto predicate = [&]( const item_reference & active_item ) {
        return location == active_item.location && active_item.item_iterator == it;
    };
    // The iterator is expected to be in this list, as it was added that way in `add`.
    // But the processing_speed may have changed, so if it's not in the expected container,
    // remove it from all containers to ensure no stale iterator remains.
    auto &expected = active_items[it->processing_speed()];
    const auto iter = std::find_if( expected.begin(), expected.end(), predicate );
    if( iter != expected.end() ) {
        expected.erase( iter );
    } else {
        for( auto &e : active_items ) {
            e.second.remove_if( predicate );
        }
    }
    if( active_item_set.erase( &*it ) == 0 ) {
        // map erase returns number of elements erased
        debugmsg( "The item isn't there!" );
    }
}