AnimatLab
2
Test
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
DoubleList.cpp
Go to the documentation of this file.
1
7
#include "stdafx.h"
8
9
namespace
IntegrateFireSim
10
{
11
namespace
Utilities
12
{
23
int
DoubleList::AddHead
(
double
d)
// add to start of list, reset iterator
24
{
25
listelem *temp=
new
listelem;
26
if
(temp==0)
27
return
0;
28
if
(head==0)
// list empty, so addition will be first & last item
29
tail=temp;
// keep track of tail of list
30
temp->next=head;
// next pointer of new element points to end of list
31
temp->data=d;
32
cursor=head=temp;
// head of list pointer points to new item
33
return
1;
34
}
35
36
// return 0 if ENOMEM
37
48
int
DoubleList::AddTail
(
double
d)
// add to end of list, reset iterator
49
{
50
listelem* temp=
new
listelem;
51
if
(temp==0)
52
return
0;
53
54
temp->next=0;
55
if
(head==0)
// list empty, so addition will be first & last item
56
cursor=head=tail=temp;
// keep track of head of list
57
else
{
58
tail->next=temp;
59
tail=temp;
60
}
61
tail->data=d;
62
return
1;
63
}
64
73
int
DoubleList::Del
(
void
)
// delete 1st item on list, reset iterator
74
{
75
if
(head==0)
76
return
0;
// empty list
77
78
listelem* temp=head;
79
cursor=head=head->next;
80
delete
temp;
81
return
1;
82
}
83
90
void
DoubleList::Release
(
void
)
91
{
92
while
(head!=0)
93
Del
();
94
cursor=0;
95
}
96
97
// Starts at head of list, returns pointer to data item, advances to next
98
// item. When at end, returns 0 and resets to start
99
108
double
*
DoubleList::Iterate
(
void
)
109
{
110
if
(cursor==0)
111
{
112
cursor=head;
113
return
0;
114
}
115
double
*d=&cursor->data;
116
cursor=cursor->next;
117
return
d;
118
}
119
128
double
DoubleList::RemoveHead
()
129
{
130
//ASSERT(IsEmpty()==false);
131
double
d=head->data;
132
listelem* temp=head;
133
cursor=head=head->next;
134
delete
temp;
135
return
d;
136
}
137
138
}
//Utilities
139
}
//IntegrateFireSim
IntegrateFireSim::Utilities::DoubleList::Del
int Del(void)
Deletes this object.
Definition:
DoubleList.cpp:73
IntegrateFireSim::Utilities::DoubleList::Iterate
double * Iterate(void)
Gets the iterate.
Definition:
DoubleList.cpp:108
IntegrateFireSim::Utilities::DoubleList::AddTail
int AddTail(double d)
Adds a tail.
Definition:
DoubleList.cpp:48
IntegrateFireSim::Utilities::DoubleList::RemoveHead
double RemoveHead()
Removes the head.
Definition:
DoubleList.cpp:128
IntegrateFireSim::Utilities::DoubleList::AddHead
int AddHead(double d)
Adds a head.
Definition:
DoubleList.cpp:23
IntegrateFireSim::Utilities::DoubleList::Release
void Release(void)
Releases this object.
Definition:
DoubleList.cpp:90
IntegrateFireSim
Contains all of the classes to implement a basic integrate and fire neural model. ...
Definition:
CaActivation.cpp:18
Libraries
IntegrateFireSim
DoubleList.cpp
Generated on Tue Sep 29 2015 07:07:14 for AnimatLab by
1.8.10