0031939: Coding - correction of spelling errors in comments [part 4]
[occt.git] / src / Interface / Interface_IntList.hxx
1 // Created on: 1995-05-12
2 // Created by: Christian CAILLET
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Interface_IntList_HeaderFile
18 #define _Interface_IntList_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Integer.hxx>
25 #include <TColStd_HArray1OfInteger.hxx>
26 #include <Standard_Boolean.hxx>
27
28 //! This class detains the data which describe a Graph. A Graph
29 //! has two lists, one for shared refs, one for sharing refs
30 //! (the reverses). Each list comprises, for each Entity of the
31 //! Model of the Graph, a list of Entities (shared or sharing).
32 //! In fact, entities are identified by their numbers in the Model
33 //! or Graph : this gives better performances.
34 //!
35 //! A simple way to implement this is to instantiate a HArray1
36 //! with a HSequenceOfInteger : each Entity Number designates a
37 //! value, which is a Sequence (if it is null, it is considered as
38 //! empty : this is a little optimisation).
39 //!
40 //! This class gives a more efficient way to implement this.
41 //! It has two lists (two arrays of integers), one to describe
42 //! list (empty, one value given immediately, or negated index in
43 //! the second list), one to store refs (pointed from the first
44 //! list). This is much more efficient than a list of sequences,
45 //! in terms of speed (especially for read) and of memory
46 //!
47 //! An IntList can also be set to access data for a given entity
48 //! number, it then acts as a single sequence
49 //!
50 //! Remark that if an IntList is created from another one, it can
51 //! be read, but if it is created without copying, it may not be
52 //! edited
53 class Interface_IntList 
54 {
55 public:
56
57   DEFINE_STANDARD_ALLOC
58
59   
60   //! Creates empty IntList.
61   Standard_EXPORT Interface_IntList();
62   
63   //! Creates an IntList for <nbe> entities
64   Standard_EXPORT Interface_IntList(const Standard_Integer nbe);
65   
66   //! Creates an IntList from another one.
67   //! if <copied> is True, copies data
68   //! else, data are not copied, only the header object is
69   Standard_EXPORT Interface_IntList(const Interface_IntList& other, const Standard_Boolean copied);
70   
71   //! Initialize IntList by number of entities.
72   Standard_EXPORT void Initialize (const Standard_Integer nbe);
73   
74   //! Returns internal values, used for copying
75   Standard_EXPORT void Internals (Standard_Integer& nbrefs, Handle(TColStd_HArray1OfInteger)& ents, Handle(TColStd_HArray1OfInteger)& refs) const;
76   
77   //! Returns count of entities to be aknowledged
78   Standard_EXPORT Standard_Integer NbEntities() const;
79   
80   //! Changes the count of entities (ignored if decreased)
81   Standard_EXPORT void SetNbEntities (const Standard_Integer nbe);
82   
83   //! Sets an entity number as current (for read and fill)
84   Standard_EXPORT void SetNumber (const Standard_Integer number);
85   
86   //! Returns the current entity number
87   Standard_EXPORT Standard_Integer Number() const;
88   
89   //! Returns an IntList, identical to <me> but set to a specified
90   //! entity Number
91   //! By default, not copied (in order to be read)
92   //! Specified <copied> to produce another list and edit it
93   Standard_EXPORT Interface_IntList List (const Standard_Integer number, const Standard_Boolean copied = Standard_False) const;
94   
95   //! Sets current entity list to be redefined or not
96   //! This is used in a Graph for redefinition list : it can be
97   //! disable (no redefinition, i.e. list is cleared), or enabled
98   //! (starts as empty). The original list has not to be "redefined"
99   Standard_EXPORT void SetRedefined (const Standard_Boolean mode);
100   
101   //! Makes a reservation for <count> references to be later
102   //! attached to the current entity. If required, it increases
103   //! the size of array used to store refs. Remark that if count is
104   //! less than two, it does nothing (because immediate storing)
105   Standard_EXPORT void Reservate (const Standard_Integer count);
106   
107   //! Adds a reference (as an integer value, an entity number) to
108   //! the current entity number. Zero is ignored
109   Standard_EXPORT void Add (const Standard_Integer ref);
110   
111   //! Returns the count of refs attached to current entity number
112   Standard_EXPORT Standard_Integer Length() const;
113
114   //! Returns True if the list for a number
115   //! (default is taken as current) is "redefined" (useful for empty list)
116   Standard_EXPORT Standard_Boolean IsRedefined (const Standard_Integer num = 0) const;
117
118   //! Returns a reference number in the list for current number,
119   //! according to its rank
120   Standard_EXPORT Standard_Integer Value (const Standard_Integer num) const;
121   
122   //! Removes an item in the list for current number, given its rank
123   //! Returns True if done, False else
124   Standard_EXPORT Standard_Boolean Remove (const Standard_Integer num);
125   
126   //! Clears all data, hence each entity number has an empty list
127   Standard_EXPORT void Clear();
128   
129   //! Resizes lists to exact sizes. For list of refs, a positive
130   //! margin can be added.
131   Standard_EXPORT void AdjustSize (const Standard_Integer margin = 0);
132
133 private:
134
135   Standard_Integer thenbe;
136   Standard_Integer thenbr;
137   Standard_Integer thenum;
138   Standard_Integer thecount;
139   Standard_Integer therank;
140   Handle(TColStd_HArray1OfInteger) theents;
141   Handle(TColStd_HArray1OfInteger) therefs;
142
143 };
144
145 #endif // _Interface_IntList_HeaderFile