Gorgon Game Engine
GarbageCollection.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #pragma warning(error: 4239)
6 
7 #include <vector>
8 #include <stdexcept>
9 #include <algorithm>
10 
11 #include "Iterator.h"
12 #include "Collection.h"
13 
14 namespace Gorgon {
15  namespace Containers {
16 
21  template<class T_, template <class ...U_> class C_=Collection>
22  class GarbageCollection : public C_<T_> {
23  public:
24 
25  void Collect() {
26  for(auto it=this->First(); it.IsValid();it.Next()) {
27  if(ShouldBeCollected(*it)) {
28  it.Delete();
29  }
30  }
31  }
32 
33  protected:
34 
35  };
36 
37  }
38 }
Collection.h
contains collection, a vector of references.
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::Containers::GarbageCollection
This class acts like a regular collection, however, it performs garbage collection over its elements.
Definition: GarbageCollection.h:22
Iterator.h
contains filesystem Iterator. Lists file and directories.
Gorgon::Containers::Collection::First
Iterator First()
returns the iterator to the first item
Definition: Collection.h:608
Gorgon::Containers::GarbageCollection::Collect
void Collect()
Definition: GarbageCollection.h:25