MFEM  v3.3
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 
22 /// A set of integers
24 {
25 private:
26  Array<int> me;
27 
28 public:
29  IntegerSet() { }
30 
32 
33  /// Create an integer set from a block of memory containing integer values
34  /// ( like an array ).
35  ///
36  /// n - length ( number of integers )
37  /// p - pointer to block of memory containing the integer values
38  IntegerSet(const int n, const int *p) { Recreate(n, p); }
39 
40  int Size() { return me.Size(); }
41 
42  operator Array<int>& () { return me; }
43 
44  int PickElement() { return me[0]; }
45 
46  int PickRandomElement();
47 
48  int operator==(IntegerSet &s);
49 
50  void Recreate(const int n, const int *p);
51 };
52 
53 /// List of integer sets
55 {
56 private:
57  Array<IntegerSet *> TheList;
58 
59 public:
60 
61  int Size() { return TheList.Size(); }
62 
63  int PickElementInSet(int i) { return TheList[i]->PickElement(); }
64 
65  int PickRandomElementInSet(int i) { return TheList[i]->PickRandomElement(); }
66 
67  int Insert(IntegerSet &s);
68 
69  int Lookup(IntegerSet &s);
70 
71  void AsTable(Table &t);
72 
74 };
75 
76 }
77 
78 #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:38
int PickRandomElement()
Definition: sets.cpp:44
int PickElementInSet(int i)
Definition: sets.hpp:63
int PickRandomElementInSet(int i)
Definition: sets.hpp:65
int operator==(IntegerSet &s)
Definition: sets.cpp:28
int Insert(IntegerSet &s)
Definition: sets.cpp:82
int Size()
Definition: sets.hpp:40
int PickElement()
Definition: sets.hpp:44
A set of integers.
Definition: sets.hpp:23
List of integer sets.
Definition: sets.hpp:54