01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * \brief Various utility functions.
feb44ad276e996ca244e071f936c61b009bd73f4johanengelen * Copyright 2007 Johan Engelen <goejendaagh@zonnet.nl>
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Copyright 2006 Michael G. Sloan <mgsloan@gmail.com>
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * This library is free software; you can redistribute it and/or
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * modify it either under the terms of the GNU Lesser General Public
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * License version 2.1 as published by the Free Software Foundation
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * (the "LGPL") or, at your option, under the terms of the Mozilla
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Public License Version 1.1 (the "MPL"). If you do not alter this
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * notice, a recipient may use your version of this file under either
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * the MPL or the LGPL.
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * You should have received a copy of the LGPL along with this library
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * in the file COPYING-LGPL-2.1; if not, write to the Free Software
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * You should have received a copy of the MPL along with this library
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * in the file COPYING-MPL-1.1
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * The contents of this file are subject to the Mozilla Public License
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Version 1.1 (the "License"); you may not use this file except in
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * compliance with the License. You may obtain a copy of the License at
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * OF ANY KIND, either express or implied. See the LGPL or the MPL for
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * the specific language governing rights and limitations.
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen// proper logical xor
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengeleninline bool logical_xor (bool a, bool b) { return (a || b) && !(a && b); }
c8589a6c7367d09fa756755cef0dd448c7328a71Johan B. C. Engelenvoid binomial_coefficients(std::vector<size_t>& bc, std::size_t n);
b980eb7f577389245ccf42ab7fa9e19801fecbd2Krzysztof Kosiński * @brief Noncommutative multiplication helper.
b980eb7f577389245ccf42ab7fa9e19801fecbd2Krzysztof Kosiński * Generates operator*(T, U) from operator*=(T, U). Does not generate operator*(U, T)
b980eb7f577389245ccf42ab7fa9e19801fecbd2Krzysztof Kosiński * like boost::multipliable does. This makes it suitable for noncommutative cases,
b980eb7f577389245ccf42ab7fa9e19801fecbd2Krzysztof Kosiński * such as transforms.
b980eb7f577389245ccf42ab7fa9e19801fecbd2Krzysztof Kosińskitemplate <class T, class U, class B = EmptyClass>
b980eb7f577389245ccf42ab7fa9e19801fecbd2Krzysztof Kosiński friend T operator*(T const &lhs, U const &rhs) {
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński/** @brief Null output iterator
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński * Use this if you want to discard a result returned through an output iterator. */
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński : public boost::output_iterator_helper<NullIterator>
b63c6af7aa7f869de42730cf0ffd8b6077d778c5Krzysztof Kosiński void operator=(T const &) {}
a16a494f042310ee849a6f717ffea70846f1f22cKrzysztof Kosiński/** @brief Get the next iterator in the container with wrap-around.
a16a494f042310ee849a6f717ffea70846f1f22cKrzysztof Kosiński * If the iterator would become the end iterator after incrementing,
a16a494f042310ee849a6f717ffea70846f1f22cKrzysztof Kosiński * return the begin iterator instead. */
a16a494f042310ee849a6f717ffea70846f1f22cKrzysztof Kosińskitemplate <typename Iter, typename Container>
a16a494f042310ee849a6f717ffea70846f1f22cKrzysztof Kosiński if (i == c.end()) {
a16a494f042310ee849a6f717ffea70846f1f22cKrzysztof Kosiński/** @brief Get the previous iterator in the container with wrap-around.
a16a494f042310ee849a6f717ffea70846f1f22cKrzysztof Kosiński * If the passed iterator is the begin iterator, return the iterator
a16a494f042310ee849a6f717ffea70846f1f22cKrzysztof Kosiński * just before the end iterator instead. */
a16a494f042310ee849a6f717ffea70846f1f22cKrzysztof Kosińskitemplate <typename Iter, typename Container>
a16a494f042310ee849a6f717ffea70846f1f22cKrzysztof Kosiński if (i == c.begin()) {
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński} // end namespace Geom
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński#endif // LIB2GEOM_SEEN_UTILS_H
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen Local Variables:
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen c-file-style:"stroustrup"
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen indent-tabs-mode:nil
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen fill-column:99
a4030d5ca449e7e384bc699cd249ee704faaeab0Chris Morgan// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :