gtsam/cpp/Ordering.h

70 lines
1.7 KiB
C
Raw Normal View History

2009-08-22 06:23:24 +08:00
/**
* @file Ordering.h
* @brief Ordering of indices for eliminating a factor graph
* @author Frank Dellaert
*/
#pragma once
2009-10-31 23:24:22 +08:00
#include <list>
2010-05-25 16:16:04 +08:00
#include <set>
2009-08-22 06:23:24 +08:00
#include <string>
2009-10-31 23:24:22 +08:00
#include "Testable.h"
#include "Key.h"
2009-08-22 06:23:24 +08:00
namespace gtsam {
/**
2009-10-07 02:01:40 +08:00
* @class Ordering
* @brief ordering of indices for eliminating a factor graph
2009-08-22 06:23:24 +08:00
*/
class Ordering: public std::list<Symbol>, public Testable<Ordering> {
2009-10-07 02:01:40 +08:00
public:
/** Default constructor creates empty ordering */
Ordering() { }
2009-10-07 02:01:40 +08:00
/** Create from a single symbol */
Ordering(Symbol key) { push_back(key); }
2009-11-09 06:51:29 +08:00
/** Copy constructor */
Ordering(const std::list<Symbol>& keys_in) : std::list<Symbol>(keys_in) {}
2010-04-09 06:16:08 +08:00
/** whether a key exists */
bool exists(const Symbol& key) { return std::find(begin(), end(), key) != end(); }
// Testable
void print(const std::string& s = "Ordering") const;
bool equals(const Ordering &ord, double tol=0) const;
2009-10-07 02:01:40 +08:00
/**
* Remove a set of keys from an ordering
* @param keys to remove
* @return a new ordering without the selected keys
*/
Ordering subtract(const Ordering& keys) const;
2009-10-07 02:01:40 +08:00
};
2009-08-22 06:23:24 +08:00
2010-05-25 16:16:04 +08:00
/**
* @class Unordered
* @brief a set of unordered indice
*/
class Unordered: public std::set<Symbol>, public Testable<Unordered> {
public:
/** Default constructor creates empty ordering */
Unordered() { }
/** Create from a single symbol */
Unordered(Symbol key) { insert(key); }
/** Copy constructor */
Unordered(const std::set<Symbol>& keys_in) : std::set<Symbol>(keys_in) {}
/** whether a key exists */
bool exists(const Symbol& key) { return find(key) != end(); }
// Testable
void print(const std::string& s = "Unordered") const;
bool equals(const Unordered &t, double tol=0) const;
};
2009-08-22 06:23:24 +08:00
}