/* * Copyright 2008-2012 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include namespace thrust { template zip_iterator ::zip_iterator(void) { } // end zip_iterator::zip_iterator() template zip_iterator ::zip_iterator(IteratorTuple iterator_tuple) :m_iterator_tuple(iterator_tuple) { } // end zip_iterator::zip_iterator() template template zip_iterator ::zip_iterator(const zip_iterator &other, typename thrust::detail::enable_if_convertible< OtherIteratorTuple, IteratorTuple >::type *) :m_iterator_tuple(other.get_iterator_tuple()) { } // end zip_iterator::zip_iterator() template const IteratorTuple &zip_iterator ::get_iterator_tuple(void) const { return m_iterator_tuple; } // end zip_iterator::get_iterator_tuple() template typename zip_iterator::super_t::reference zip_iterator ::dereference(void) const { using namespace detail::tuple_impl_specific; return thrust::detail::tuple_host_device_transform(get_iterator_tuple(), detail::dereference_iterator()); } // end zip_iterator::dereference() __thrust_hd_warning_disable__ template template bool zip_iterator ::equal(const zip_iterator &other) const { return get<0>(get_iterator_tuple()) == get<0>(other.get_iterator_tuple()); } // end zip_iterator::equal() template void zip_iterator ::advance(typename super_t::difference_type n) { using namespace detail::tuple_impl_specific; // XXX note that we use a pointer to System to dispatch to avoid // default construction of a System typename thrust::iterator_system::type *use_me_to_dispatch = 0; // dispatch on system tuple_for_each(m_iterator_tuple, detail::advance_iterator(n), use_me_to_dispatch); } // end zip_iterator::advance() template void zip_iterator ::increment(void) { using namespace detail::tuple_impl_specific; // XXX note that we use a pointer to System to dispatch to avoid // default construction of a System typename thrust::iterator_system::type *use_me_to_dispatch = 0; // dispatch on system tuple_for_each(m_iterator_tuple, detail::increment_iterator(), use_me_to_dispatch); } // end zip_iterator::increment() template void zip_iterator ::decrement(void) { using namespace detail::tuple_impl_specific; // XXX note that we use a pointer to System to dispatch to avoid // default construction of a System typename thrust::iterator_system::type *use_me_to_dispatch = 0; // dispatch on system tuple_for_each(m_iterator_tuple, detail::decrement_iterator(), use_me_to_dispatch); } // end zip_iterator::decrement() __thrust_hd_warning_disable__ template template typename zip_iterator::super_t::difference_type zip_iterator ::distance_to(const zip_iterator &other) const { return get<0>(other.get_iterator_tuple()) - get<0>(get_iterator_tuple()); } // end zip_iterator::distance_to() template zip_iterator make_zip_iterator(IteratorTuple t) { return zip_iterator(t); } // end make_zip_iterator() } // end thrust