libigl v2.5.0
Loading...
Searching...
No Matches
SortableRow.h
Go to the documentation of this file.
1// This file is part of libigl, a simple c++ geometry processing library.
2//
3// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
4//
5// This Source Code Form is subject to the terms of the Mozilla Public License
6// v. 2.0. If a copy of the MPL was not distributed with this file, You can
7// obtain one at http://mozilla.org/MPL/2.0/.
8#ifndef IGL_SORTABLE_ROW_H
9#define IGL_SORTABLE_ROW_H
10
11// Simple class to contain a rowvector which allows rowwise sorting and
12// reordering
13#include <Eigen/Core>
14
15namespace igl
16{
19 template <typename T>
21 {
22 public:
25 public:
30 SortableRow(const T & data):data(data){};
34 bool operator<(const SortableRow & that) const
35 {
36 // Lexicographical
37 int minc = (this->data.size() < that.data.size()?
38 this->data.size() : that.data.size());
39 // loop over columns
40 for(int i = 0;i<minc;i++)
41 {
42 if(this->data(i) == that.data(i))
43 {
44 continue;
45 }
46 return this->data(i) < that.data(i);
47 }
48 // All characters the same, comes done to length
49 return this->data.size()<that.data.size();
50 };
54 bool operator==(const SortableRow & that) const
55 {
56 if(this->data.size() != that.data.size())
57 {
58 return false;
59 }
60 for(int i = 0;i<this->data.size();i++)
61 {
62 if(this->data(i) != that.data(i))
63 {
64 return false;
65 }
66 }
67 return true;
68 };
72 bool operator!=(const SortableRow & that) const
73 {
74 return !(*this == that);
75 };
76 };
77}
78
79#endif
A row of things that can be sorted against other rows.
Definition SortableRow.h:21
bool operator!=(const SortableRow &that) const
Inequality comparison.
Definition SortableRow.h:72
bool operator==(const SortableRow &that) const
Equality comparison.
Definition SortableRow.h:54
bool operator<(const SortableRow &that) const
Less than comparison.
Definition SortableRow.h:34
T data
The data.
Definition SortableRow.h:24
SortableRow()
Default constructor.
Definition SortableRow.h:27
SortableRow(const T &data)
Constructor.
Definition SortableRow.h:30
Definition AABB.h:17