LIBINT  2.1.0-stable
drtree.h
1 /*
2  * This file is a part of Libint.
3  * Copyright (C) 2004-2014 Edward F. Valeev
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see http://www.gnu.org/licenses/.
17  *
18  */
19 
20 #ifndef _libint2_src_bin_libint_drtree_h_
21 #define _libint2_src_bin_libint_drtree_h_
22 
23 #include <smart_ptr.h>
24 
25 namespace libint2 {
26 
27  class DGVertex;
28 
30  class DRTree :
31  public EnableSafePtrFromThis<DRTree>
32  {
33  public:
34  typedef DRTree this_type;
35 
37  static SafePtr<DRTree> CreateRootedAt(const SafePtr<DGVertex>& v);
38  ~DRTree();
39 
41  unsigned int nvertices() const { return nvertices_; }
43  const SafePtr<DGVertex>& root() const;
45  void detach();
47  void add_vertex(const SafePtr<DGVertex>& v);
49  void detach_from(const SafePtr<DGVertex>& v);
50 
51  private:
53  DRTree(const SafePtr<DGVertex>& root);
55  void grow();
56 
57  unsigned int nvertices_;
58  SafePtr<DGVertex> root_;
59  };
60 
61 }
62 
63 #endif // ifndef
64 
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:23
unsigned int nvertices() const
number of vertices
Definition: drtree.h:41
void detach()
remove all references from vertices to the tree and vice versa
Definition: drtree.cc:88
static SafePtr< DRTree > CreateRootedAt(const SafePtr< DGVertex > &v)
If v is not on a DRTree, make a new one using v as root.
Definition: drtree.cc:28
void add_vertex(const SafePtr< DGVertex > &v)
will try to add v to this subtree. Should not be used by the user
Definition: drtree.cc:64
void detach_from(const SafePtr< DGVertex > &v)
recurively detach v from this
Definition: drtree.cc:94
const SafePtr< DGVertex > & root() const
the root of the tree
Definition: drtree.cc:58
This is a directed rooted tree.
Definition: drtree.h:30