b311480e |
1 | // Copyright (c) 1992-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
b311480e |
14 | |
7fd59977 |
15 | //-Version: |
16 | |
7fd59977 |
17 | // Version Date Purpose |
18 | // 07/01/93 Creation |
19 | |
20 | //-Language C++2.0 |
21 | |
22 | //-Declarations |
23 | #include <Standard_NoSuchObject.hxx> |
24 | #include <Standard_NoMoreObject.hxx> |
25 | |
26 | //======================================================================= |
27 | // Function : DoubleMapIterator |
28 | //======================================================================= |
29 | |
30 | PCollection_DoubleMapIterator::PCollection_DoubleMapIterator |
31 | ( const Handle(PCollection_HDoubleMap) &aDoubleMap ) |
32 | { |
33 | Standard_Boolean Found = Standard_False; |
34 | |
35 | myBuckets = aDoubleMap->GetArrayKey(); |
36 | // Sets the index and the node on the first "no empty" entry |
37 | if ( aDoubleMap->IsEmpty() ) myCurrentIndex = myBuckets->Length() + 1; |
38 | else myCurrentIndex = 1; |
39 | |
40 | while ( myCurrentIndex <= myBuckets->Length() && !Found ) { |
41 | if ( ! myBuckets->Value(myCurrentIndex).IsNull() ) { |
42 | myCurrentNode = myBuckets->Value(myCurrentIndex); |
43 | Found = Standard_True; |
44 | } |
45 | else myCurrentIndex++; |
46 | } |
47 | } |
48 | |
49 | //======================================================================= |
50 | // Function : More |
51 | //======================================================================= |
52 | |
53 | Standard_Boolean PCollection_DoubleMapIterator::More() const |
54 | { |
55 | Standard_Boolean Ok = ( myCurrentIndex <= myBuckets->Length()) && |
56 | (! myCurrentNode.IsNull()); |
57 | |
58 | return Ok; |
59 | } |
60 | |
61 | //======================================================================= |
62 | // Function : Next |
63 | //======================================================================= |
64 | |
65 | void PCollection_DoubleMapIterator::Next() |
66 | { |
67 | Standard_Boolean Found = Standard_False; |
68 | Standard_Boolean HasMore = ( myCurrentIndex <= myBuckets->Length()) && |
69 | (! myCurrentNode.IsNull()); |
70 | |
71 | if ( !HasMore ) Standard_NoMoreObject::Raise(); |
72 | |
73 | myCurrentNode = myCurrentNode->NextKey(); |
74 | if ( myCurrentNode.IsNull() ) { |
75 | myCurrentIndex++; |
76 | while ( myCurrentIndex <= myBuckets->Length() && !Found ) { |
77 | myCurrentNode = myBuckets->Value(myCurrentIndex); |
78 | if ( myCurrentNode.IsNull() ) |
79 | myCurrentIndex++; |
80 | else |
81 | Found = Standard_True; |
82 | } |
83 | } |
84 | |
85 | } |
86 | |
87 | //======================================================================= |
88 | // Function : KeyValue |
89 | //======================================================================= |
90 | |
91 | Key PCollection_DoubleMapIterator::KeyValue () const |
92 | { |
93 | if ( myCurrentNode.IsNull() ) Standard_NoSuchObject::Raise(); |
94 | return myCurrentNode->GetKey(); |
95 | } |
96 | |
97 | //======================================================================= |
98 | // Function : ItemValue |
99 | //======================================================================= |
100 | |
101 | Item PCollection_DoubleMapIterator::ItemValue () const |
102 | { |
103 | if ( myCurrentNode.IsNull() ) Standard_NoSuchObject::Raise(); |
104 | return myCurrentNode->GetItem(); |
105 | } |