7fd59977 |
1 | // File: TCollection_SList.gxx |
2 | // Created: Fri Feb 26 14:18:34 1993 |
3 | // Author: Remi LEQUETTE |
4 | // <rle@phylox> |
5 | |
6 | #include <Standard_NoSuchObject.hxx> |
7 | |
8 | //======================================================================= |
9 | //function : TCollection_SList |
10 | //purpose : |
11 | //======================================================================= |
12 | |
13 | TCollection_SList::TCollection_SList() |
14 | {} |
15 | |
16 | //======================================================================= |
17 | //function : TCollection_SList |
18 | //purpose : |
19 | //======================================================================= |
20 | |
21 | TCollection_SList::TCollection_SList(const Item& anItem, |
22 | const TCollection_SList& aTail) : |
23 | myNode(new TCollection_SListNode(anItem,aTail)) |
24 | {} |
25 | |
26 | //======================================================================= |
27 | //function : TCollection_SList |
28 | //purpose : |
29 | //======================================================================= |
30 | |
31 | TCollection_SList::TCollection_SList(const TCollection_SList& Other) : |
32 | myNode(Other.myNode) |
33 | { |
34 | } |
35 | |
36 | //======================================================================= |
37 | //function : Assign |
38 | //purpose : |
39 | //======================================================================= |
40 | |
41 | TCollection_SList& TCollection_SList::Assign(const TCollection_SList& Other) |
42 | { |
43 | if (this == &Other) return *this; |
44 | Clear(); |
45 | myNode = Other.myNode; |
46 | |
47 | return *this; |
48 | } |
49 | |
50 | //======================================================================= |
51 | //function : Clear |
52 | //purpose : |
53 | //======================================================================= |
54 | |
55 | void TCollection_SList::Clear() |
56 | { |
57 | if (!myNode.IsNull()) { |
58 | myNode.Nullify(); |
59 | } |
60 | } |
61 | |
62 | //======================================================================= |
63 | //function : Value |
64 | //purpose : |
65 | //======================================================================= |
66 | |
67 | const Item& TCollection_SList::Value() const |
68 | { |
69 | Standard_NoSuchObject_Raise_if(myNode.IsNull(),"TCollection_SList::Value"); |
70 | return myNode->Value(); |
71 | } |
72 | |
73 | //======================================================================= |
74 | //function : ChangeValue |
75 | //purpose : |
76 | //======================================================================= |
77 | |
78 | Item& TCollection_SList::ChangeValue() |
79 | { |
80 | Standard_NoSuchObject_Raise_if(myNode.IsNull(),"TCollection_SList::Value"); |
81 | return myNode->Value(); |
82 | } |
83 | |
84 | //======================================================================= |
85 | //function : SetValue |
86 | //purpose : |
87 | //======================================================================= |
88 | |
89 | void TCollection_SList::SetValue(const Item& anItem) |
90 | { |
91 | Standard_NoSuchObject_Raise_if(myNode.IsNull(),"TCollection_SList::Value"); |
92 | myNode->Value() = anItem; |
93 | } |
94 | |
95 | //======================================================================= |
96 | //function : Tail |
97 | //purpose : |
98 | //======================================================================= |
99 | |
100 | const TCollection_SList& TCollection_SList::Tail() const |
101 | { |
102 | if (!myNode.IsNull()) |
103 | return myNode->Tail(); |
104 | else |
105 | return *this; |
106 | } |
107 | |
108 | //======================================================================= |
109 | //function : ChangeTail |
110 | //purpose : |
111 | //======================================================================= |
112 | |
113 | TCollection_SList& TCollection_SList::ChangeTail() |
114 | { |
115 | if (!myNode.IsNull()) |
116 | return myNode->Tail(); |
117 | else |
118 | return *this; |
119 | } |
120 | |
121 | //======================================================================= |
122 | //function : SetTail |
123 | //purpose : |
124 | //======================================================================= |
125 | |
126 | void TCollection_SList::SetTail(const TCollection_SList& aList) |
127 | { |
128 | if (!myNode.IsNull()) |
129 | myNode->Tail() = aList; |
130 | else |
131 | Assign(aList); |
132 | } |