76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński/** @file
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński * @brief Comparator template
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński *//*
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * Authors:
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * ? <?@?.?>
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould *
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * Copyright ?-? authors
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould *
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * This library is free software; you can redistribute it and/or
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * modify it either under the terms of the GNU Lesser General Public
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * License version 2.1 as published by the Free Software Foundation
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * (the "LGPL") or, at your option, under the terms of the Mozilla
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * Public License Version 1.1 (the "MPL"). If you do not alter this
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * notice, a recipient may use your version of this file under either
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * the MPL or the LGPL.
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould *
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * You should have received a copy of the LGPL along with this library
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * in the file COPYING-LGPL-2.1; if not, write to the Free Software
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * You should have received a copy of the MPL along with this library
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * in the file COPYING-MPL-1.1
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould *
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * The contents of this file are subject to the Mozilla Public License
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * Version 1.1 (the "License"); you may not use this file except in
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * compliance with the License. You may obtain a copy of the License at
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * http://www.mozilla.org/MPL/
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould *
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * OF ANY KIND, either express or implied. See the LGPL or the MPL for
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould * the specific language governing rights and limitations.
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould *
01d27eab5fca2dcb8e883011f8be77ae6b78a11cTed Gould */
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński#ifndef LIB2GEOM_SEEN_ORD_H
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński#define LIB2GEOM_SEEN_ORD_H
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelennamespace {
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruzenum Cmp {
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruz LESS_THAN=-1,
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruz GREATER_THAN=1,
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruz EQUAL_TO=0
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruz};
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen
c8589a6c7367d09fa756755cef0dd448c7328a71Johan B. C. Engelenstatic inline Cmp operator-(Cmp x) {
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen switch(x) {
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen case LESS_THAN:
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen return GREATER_THAN;
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen case GREATER_THAN:
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen return LESS_THAN;
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen case EQUAL_TO:
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen return EQUAL_TO;
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen }
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen}
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruz
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruztemplate <typename T1, typename T2>
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruzinline Cmp cmp(T1 const &a, T2 const &b) {
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruz if ( a < b ) {
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruz return LESS_THAN;
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruz } else if ( b < a ) {
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruz return GREATER_THAN;
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruz } else {
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruz return EQUAL_TO;
182486105ac34c36a2c74e775bcb44d5cbbaffacjoncruz }
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen}
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen}
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen#endif
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen/*
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen Local Variables:
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen mode:c++
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
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen End:
63267518b4ce196caab66ef8cbdcfc0921206b3djohanengelen*/
a4030d5ca449e7e384bc699cd249ee704faaeab0Chris Morgan// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :