void print_tuple(const tuple_type& tuple)
{
    if(tuple.empty())
    {
        hpx::cout<<"()";
        return;
    }

    tuple_type::const_iterator it = tuple.begin();
    hpx::cout<<"("<<*it;
    for(++it; it != tuple.end(); ++it)
    {
        hpx::cout<<", "<<*it;
    }
    hpx::cout<<")";
}
Beispiel #2
0
            int insert(const tuple_type& tp)
            {
                if(tp.empty()) // empty tuple
                    return -1;

                // whether size(tp) > size(tuple_fields_)
                while(tp.size() > tuple_fields_.size())
                {
                    tuple_field_container tmp;
                    tuple_fields_.push_back(tmp);
                }

                tuple_type::const_iterator it;
                unsigned int pos;
                for(it = tp.begin(), pos = 0; it != tp.end(); ++it, ++pos)
                {
                    tuple_fields_[pos].insert(index_, *it); // insert field
                }

                ++index_; // step up the index
                return 0;
            }
Beispiel #3
0
            matched_indices_type find_matched_indices(const tuple_type& tp) const
            {
                tuple_type::const_iterator it;
                unsigned int pos;

                matched_indices_type matched_indices, empty_set;

                for(it = tp.begin(), pos = 0; it != tp.end(); ++it, ++pos)
                {
                    if((*it).empty()) // empty any object
                    {
                        continue; // will match any record
                    }

                    typedef std::pair<tuple_field_container
                        ::field_index_map_const_iterator_type,
                        tuple_field_container::field_index_map_const_iterator_type>
                        equal_range_type;
                    typedef const std::pair<elem_type, index_type> pair_type;

                    equal_range_type found_range =
                        tuple_fields_[pos].field_index_map_.equal_range(*it);

                    if(found_range.first == tuple_fields_[pos].field_index_map_.end())
                    // no match
                    {
                        return empty_set; // empty
                    }

                    // update index set
                    if(matched_indices.empty()) // not found yet
                    {
                        std::for_each(found_range.first,
                            found_range.second,
                            [&matched_indices](pair_type& p)
                        { matched_indices.insert(p.second); }
                        );
                    }
                    else
                    {
                        matched_indices_type new_matched_indices;

                        std::for_each(found_range.first,
                            found_range.second,
                            [&new_matched_indices, &matched_indices](pair_type& p)
                        { if(matched_indices.find(p.second) !=
                        matched_indices.end()) // found
                        { new_matched_indices.insert(p.second); }
                        }
                        );

                        if(new_matched_indices.empty()) // no common index
                        {
                            return empty_set;
                        }
                        else
                        {
                            matched_indices = new_matched_indices;
                        }
                    }

                }

                return matched_indices;
            }