summaryrefslogtreecommitdiff
path: root/inc/PCollection_HDoubleList.gxx
blob: 5fedfa7a0bb5ace709441fc39fd7f49622df3e50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// -----------------------------------------------------------------------
// -                                                                     -
// -                      HDoubleList                                     -
// -                                                                     -
// -----------------------------------------------------------------------



#include <Standard_NoSuchObject.hxx>
#include <Standard_NotImplemented.hxx>

// -----------------------------------------------------------------------
// -                                                                     -
// -                                                                     -
// -                                                                     -
// -----------------------------------------------------------------------
PCollection_HDoubleList::PCollection_HDoubleList ( ){
}


// -----------------------------------------------------------------------
// -                                                                     -
// -                                                                     -
// -                                                                     -
// -----------------------------------------------------------------------
Handle(PCollection_HDoubleList) 
   PCollection_HDoubleList::Construct(const Item& T)
{

 Handle(PCollection_HDoubleList) me , L ;
 me = this;
 L  = new PCollection_HDoubleList;
 L->ChangeForwardPointer ( me );  // Pointeur avant de L sur me.
 Before = L;                      // Pointer arriere de me sur L.
 L->SetValue ( T );               // Mettre la valeur de l'item.
 return L;                        // C'est L qui est retourne.
}


// -----------------------------------------------------------------------
// -                                                                     -
// -                                                                     -
// -                                                                     -
// -----------------------------------------------------------------------
Handle(Standard_Persistent) PCollection_HDoubleList::ShallowCopy() const
{
  
  Handle(PCollection_HDoubleList) TheList,          // Traversal depth of <this>
                                TheCopy,          // The list returned
                                Pred,             // Backward pointer
                                Succ,             // Forward pointer
                                Last;             // Last cell

  TheCopy = new PCollection_HDoubleList;            // Initialization of the list
                                                  // that will be returned
  Standard_Boolean FirstTime = Standard_True;                 

  TheList = this;                                 // Start at the beginning
  Pred = Succ = TheCopy;
  
  while ( ! TheList->IsEmpty() ) {                // Append each item at the
    Succ = Succ->Construct(TheList->Value());     // end of the list
    if ( FirstTime ){
      FirstTime = Standard_False;
      TheCopy   = Succ;
    }
    else{
      Pred->ChangeForwardPointer(Succ);           // Make the link between 
      Succ->ChangeBackPointer(Pred);              // Pred and Succ
    }
    Pred = Succ;
    Succ = Succ->Tail();
    TheList = TheList->Tail();                   
  }
  return TheCopy;                                // Returns the header
}

// -----------------------------------------------------------------------
// -                                                                     -
// -                                                                     -
// -                                                                     -
// -----------------------------------------------------------------------
void PCollection_HDoubleList::ShallowDump(Standard_OStream& S) const
{
  Handle(PCollection_HDoubleList) TheList;
  TheList = this;
  S << "begin class HDoubleList " << endl;
  while ( ! TheList->IsEmpty() ) {                
    ::ShallowDump(TheList->Value(), S);
    TheList = TheList->Tail();
  }
  S << "end of HDoubleList." << endl;
}


/* Anciens INLINE */


void PCollection_HDoubleList::ChangeForwardPointer
   (const Handle(PCollection_HDoubleList)& L)
{
     Next = L;
}

void PCollection_HDoubleList::ChangeBackPointer
   (const Handle(PCollection_HDoubleList)& L)
{
    Before  = L;
}


void PCollection_HDoubleList::SetValue(const Item& T)
{
  Standard_NoSuchObject_Raise_if (IsEmpty(),
                                  "Empty Element in HDoubleList::SetValue");
  Data = T;
}


Item PCollection_HDoubleList::Value() const {
  Standard_NoSuchObject_Raise_if(IsEmpty(),
                                    "Empty Element in HDoubleList::Value");
  return Data;
}

Handle(PCollection_HDoubleList) PCollection_HDoubleList::Previous() const {
  Standard_NoSuchObject_Raise_if((IsEmpty() && Before.IsNull()),
                                 "Empty Element in HDoubleList::Previous");
  return Before;
}


Standard_Boolean PCollection_HDoubleList::IsEmpty()const
{
  return Next.IsNull();
}


Handle(PCollection_HDoubleList) PCollection_HDoubleList::Tail() const {
  Standard_NoSuchObject_Raise_if(IsEmpty(),
                                 "Empty Element in HDoubleList::Previous");
  return Next;
}

// -----------------------------------------------------------------------
// -                                                                     -
// -                                                                     -
// -                                                                     -
// -----------------------------------------------------------------------
void PCollection_HDoubleList::SwapTail(Handle(PCollection_HDoubleList)&
                                            WithList)
{
 // Exception si liste vide
  Standard_NoSuchObject_Raise_if(IsEmpty(),
                                 "Empty Element in HDoubleList::SwapTail") ;

  Handle(PCollection_HDoubleList) L  = Next;
  Handle(PCollection_HDoubleList) me ;
  me = this;
  WithList->ChangeBackPointer(me);
  Next = WithList;
  WithList = L;
}

void PCollection_HDoubleList::Destroy()
{
#ifdef CSFDB 
  Next.Nullify();
#endif
}