MueLu
Version of the Day
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
MueLu_LinkedList.cpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// MueLu: A package for multigrid based preconditioning
4
//
5
// Copyright 2012 NTESS and the MueLu contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#include <stddef.h>
// for NULL
11
#include "
MueLu_LinkedList.hpp
"
12
13
namespace
MueLu {
14
15
LinkedList::LinkedList
()
16
: nodeHead(NULL)
17
, nodeTail(NULL) {}
18
19
LinkedList::~LinkedList
() {
20
while
(
nodeHead
!= NULL)
21
DeleteHead
();
22
}
23
24
bool
LinkedList::IsEmpty
() {
25
return
nodeHead
== NULL;
26
}
27
28
void
LinkedList::Add
(
int
iNode) {
29
MueLu_Node
*newNode =
new
MueLu_Node
;
30
newNode->
nodeId
= iNode;
31
newNode->
next
= NULL;
32
if
(
nodeHead
== NULL) {
33
nodeHead
= newNode;
34
nodeTail
= newNode;
35
}
else
{
36
nodeTail
->
next
= newNode;
37
nodeTail
= newNode;
38
}
39
}
40
41
int
LinkedList::Pop
() {
// get head and remove first node
42
if
(
IsEmpty
())
return
-1;
43
44
int
iNode =
nodeHead
->
nodeId
;
45
DeleteHead
();
46
return
iNode;
47
}
48
49
void
LinkedList::DeleteHead
() {
50
if
(
IsEmpty
())
return
;
51
52
MueLu_Node
*newNode =
nodeHead
;
53
nodeHead
= newNode->
next
;
54
delete
newNode;
55
}
56
57
}
// namespace MueLu
58
59
// TODO: nodeTail unused -> remove?
MueLu::MueLu_Node
struct MueLu::MueLu_Node_Struct MueLu_Node
MueLu::MueLu_Node_Struct
Definition:
MueLu_LinkedList.hpp:19
MueLu_LinkedList.hpp
MueLu::LinkedList::nodeHead
MueLu_Node * nodeHead
Definition:
MueLu_LinkedList.hpp:37
MueLu::MueLu_Node_Struct::nodeId
int nodeId
Definition:
MueLu_LinkedList.hpp:20
MueLu::LinkedList::~LinkedList
~LinkedList()
Definition:
MueLu_LinkedList.cpp:19
MueLu::MueLu_Node_Struct::next
struct MueLu_Node_Struct * next
Definition:
MueLu_LinkedList.hpp:21
MueLu::LinkedList::DeleteHead
void DeleteHead()
Definition:
MueLu_LinkedList.cpp:49
MueLu::LinkedList::Pop
int Pop()
Definition:
MueLu_LinkedList.cpp:41
MueLu::LinkedList::nodeTail
MueLu_Node * nodeTail
Definition:
MueLu_LinkedList.hpp:38
MueLu::LinkedList::LinkedList
LinkedList()
Definition:
MueLu_LinkedList.cpp:15
MueLu::LinkedList::Add
void Add(int iNode)
Definition:
MueLu_LinkedList.cpp:28
MueLu::LinkedList::IsEmpty
bool IsEmpty()
Definition:
MueLu_LinkedList.cpp:24
src
Graph
Containers
MueLu_LinkedList.cpp
Generated on Fri Nov 22 2024 09:17:05 for MueLu by
1.8.5