Macaulay2 Engine
Loading...
Searching...
No Matches
hash.hpp
Go to the documentation of this file.
1// Copyright 2002-2016 Michael E. Stillman
2#ifndef _hash_hh_
3#define _hash_hh_
4
41
42#include "newdelete.hpp"
43#include <cassert>
44#include <M2/gc-include.h>
45
60//class EngineObject : public gc
62{
63 private:
64 mutable unsigned int mHashValue;
65 public:
67
68 virtual ~EngineObject() { /* nothing to do here */ }
69
70 unsigned int hash() const
71 {
72 if (mHashValue == 0)
73 {
75 if (mHashValue == 0) mHashValue = 1;
76 }
77 return mHashValue;
78 }
79
80 protected:
81 virtual unsigned int computeHashValue() const = 0;
82};
83
98{
99 private:
100 static unsigned int mNextMutableHashValue;
101 unsigned int mHashValue;
102
103 public:
105 virtual ~MutableEngineObject() { /* nothing to do here */ }
106 unsigned int hash() const { return mHashValue; }
107};
108
109#endif
110
111// Local Variables:
112// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
113// indent-tabs-mode: nil
114// End:
EngineObject()
Definition hash.hpp:66
virtual unsigned int computeHashValue() const =0
unsigned int hash() const
Definition hash.hpp:70
unsigned int mHashValue
Definition hash.hpp:64
virtual ~EngineObject()
Definition hash.hpp:68
virtual ~MutableEngineObject()
Definition hash.hpp:105
unsigned int mHashValue
Definition hash.hpp:101
static unsigned int mNextMutableHashValue
Definition hash.hpp:100
unsigned int hash() const
Definition hash.hpp:106
our_new_delete — per-class opt-in routing of new / delete through bdwgc.