MFEM  v3.2
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
sets.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_SETS
13 #define MFEM_SETS
14 
15 #include "../config/config.hpp"
16 #include "array.hpp"
17 #include "table.hpp"
18 
19 namespace mfem
20 {
21 
24 {
25 private:
26  Array<int> me;
27 
28 public:
29  IntegerSet() { }
30 
32 
33  IntegerSet(const int n, const int *p) { Recreate(n, p); }
34 
35  int Size() { return me.Size(); }
36 
37  operator Array<int>& () { return me; }
38 
39  int PickElement() { return me[0]; }
40 
41  int PickRandomElement();
42 
43  int operator==(IntegerSet &s);
44 
45  void Recreate(const int n, const int *p);
46 };
47 
50 {
51 private:
52  Array<IntegerSet *> TheList;
53 
54 public:
55 
56  int Size() { return TheList.Size(); }
57 
58  int PickElementInSet(int i) { return TheList[i]->PickElement(); }
59 
60  int PickRandomElementInSet(int i) { return TheList[i]->PickRandomElement(); }
61 
62  int Insert(IntegerSet &s);
63 
64  int Lookup(IntegerSet &s);
65 
66  void AsTable(Table &t);
67 
69 };
70 
71 }
72 
73 #endif
int Lookup(IntegerSet &s)
Definition: sets.cpp:95
int Size() const
Logical size of the array.
Definition: array.hpp:109
void Recreate(const int n, const int *p)
Definition: sets.cpp:59
void AsTable(Table &t)
Definition: sets.cpp:107
IntegerSet(const int n, const int *p)
Definition: sets.hpp:33
int PickRandomElement()
Definition: sets.cpp:44
int PickElementInSet(int i)
Definition: sets.hpp:58
int PickRandomElementInSet(int i)
Definition: sets.hpp:60
int operator==(IntegerSet &s)
Definition: sets.cpp:28
int Insert(IntegerSet &s)
Definition: sets.cpp:82
int Size()
Definition: sets.hpp:35
int PickElement()
Definition: sets.hpp:39
A set of integers.
Definition: sets.hpp:23
List of integer sets.
Definition: sets.hpp:49