Move methods with more than two lines to outside of class definition

This commit is contained in:
Tiago Gomes
2013-02-06 00:24:02 +00:00
parent 0d9d59f5fe
commit 42a5bc493a
25 changed files with 1442 additions and 856 deletions

View File

@@ -26,10 +26,10 @@ class Symbol
static Symbol invalid (void) { return Symbol(); }
friend ostream& operator<< (ostream &os, const Symbol& s);
private:
unsigned id_;
friend ostream& operator<< (ostream &os, const Symbol& s);
};
@@ -42,35 +42,50 @@ class LogVar
operator unsigned (void) const { return id_; }
LogVar& operator++ (void)
{
assert (valid());
id_ ++;
return *this;
}
LogVar& operator++ (void);
bool valid (void) const
{
return id_ != Util::maxUnsigned();
}
friend ostream& operator<< (ostream &os, const LogVar& X);
bool valid (void) const;
private:
unsigned id_;
friend ostream& operator<< (ostream &os, const LogVar& X);
};
inline LogVar&
LogVar::operator++ (void)
{
assert (valid());
id_ ++;
return *this;
}
inline bool
LogVar::valid (void) const
{
return id_ != Util::maxUnsigned();
}
namespace std {
template <> struct hash<Symbol> {
size_t operator() (const Symbol& s) const {
return std::hash<unsigned>() (s);
}};
}
};
template <> struct hash<LogVar> {
size_t operator() (const LogVar& X) const {
return std::hash<unsigned>() (X);
}};
}
};
};
@@ -87,8 +102,11 @@ ostream& operator<< (ostream &os, const Tuple& t);
namespace LiftedUtils {
Symbol getSymbol (const string&);
void printSymbolDictionary (void);
void printSymbolDictionary (void);
}
@@ -108,11 +126,11 @@ class Ground
bool isAtom (void) const { return args_.empty(); }
friend ostream& operator<< (ostream &os, const Ground& gr);
private:
Symbol functor_;
Symbols args_;
friend ostream& operator<< (ostream &os, const Ground& gr);
};
typedef vector<Ground> Grounds;
@@ -122,43 +140,73 @@ typedef vector<Ground> Grounds;
class Substitution
{
public:
void add (LogVar X_old, LogVar X_new)
{
assert (Util::contains (subs_, X_old) == false);
subs_.insert (make_pair (X_old, X_new));
}
void add (LogVar X_old, LogVar X_new);
void rename (LogVar X_old, LogVar X_new)
{
assert (Util::contains (subs_, X_old));
subs_.find (X_old)->second = X_new;
}
void rename (LogVar X_old, LogVar X_new);
LogVar newNameFor (LogVar X) const
{
unordered_map<LogVar, LogVar>::const_iterator it;
it = subs_.find (X);
if (it != subs_.end()) {
return subs_.find (X)->second;
}
return X;
}
LogVar newNameFor (LogVar X) const;
bool containsReplacementFor (LogVar X) const
{
return Util::contains (subs_, X);
}
bool containsReplacementFor (LogVar X) const;
size_t nrReplacements (void) const { return subs_.size(); }
size_t nrReplacements (void) const;
LogVars getDiscardedLogVars (void) const;
friend ostream& operator<< (ostream &os, const Substitution& theta);
private:
unordered_map<LogVar, LogVar> subs_;
friend ostream& operator<< (ostream &os, const Substitution& theta);
};
inline void
Substitution::add (LogVar X_old, LogVar X_new)
{
assert (Util::contains (subs_, X_old) == false);
subs_.insert (make_pair (X_old, X_new));
}
inline void
Substitution::rename (LogVar X_old, LogVar X_new)
{
assert (Util::contains (subs_, X_old));
subs_.find (X_old)->second = X_new;
}
inline LogVar
Substitution::newNameFor (LogVar X) const
{
unordered_map<LogVar, LogVar>::const_iterator it;
it = subs_.find (X);
if (it != subs_.end()) {
return subs_.find (X)->second;
}
return X;
}
inline bool
Substitution::containsReplacementFor (LogVar X) const
{
return Util::contains (subs_, X);
}
inline size_t
Substitution::nrReplacements (void) const
{
return subs_.size();
}
#endif // HORUS_LIFTEDUTILS_H