From: skv Date: Wed, 9 Jul 2014 10:53:35 +0000 (+0400) Subject: 0025064: TCollection modification for Salome porting X-Git-Tag: V6_8_0_beta~203 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=214df550f61c14b6a25e11a46753afedd09c62dd;p=occt-copy.git 0025064: TCollection modification for Salome porting --- diff --git a/src/TCollection/TCollection_IndexedMap.cdl b/src/TCollection/TCollection_IndexedMap.cdl index 262d644c04..3144204f0d 100644 --- a/src/TCollection/TCollection_IndexedMap.cdl +++ b/src/TCollection/TCollection_IndexedMap.cdl @@ -84,14 +84,9 @@ is -- - the function RemoveLast to remove the last entry from the map. Create(Other : IndexedMap from TCollection) - returns IndexedMap from TCollection + returns IndexedMap from TCollection; ---Purpose: As copying Map is an expensive operation it is - -- incorrect to do it implicitly. This constructor - -- will raise an error if the Map is not empty. To - -- copy the content of a Map use the Assign method (operator =). - raises DomainError from Standard - is private; - + -- not recommended to do it implicitly. Assign(me : in out; Other : IndexedMap from TCollection) returns IndexedMap from TCollection diff --git a/src/TCollection/TCollection_IndexedMap.gxx b/src/TCollection/TCollection_IndexedMap.gxx index e20aa6445d..5e4ecdca49 100644 --- a/src/TCollection/TCollection_IndexedMap.gxx +++ b/src/TCollection/TCollection_IndexedMap.gxx @@ -41,8 +41,12 @@ TCollection_IndexedMap::TCollection_IndexedMap (const TCollection_IndexedMap& Other) : TCollection_BasicMap(Other.NbBuckets(),Standard_False) { - if (!Other.IsEmpty()) - Standard_DomainError::Raise("TCollection:Copy of IndexedMap"); + if (!Other.IsEmpty()) { + ReSize(Other.Extent()); + for (Standard_Integer i = 1; i <= Other.Extent(); i++) { + Add(Other(i)); + } + } } //======================================================================= diff --git a/src/TCollection/TCollection_List.cdl b/src/TCollection/TCollection_List.cdl index cfaffaf041..1370528c73 100644 --- a/src/TCollection/TCollection_List.cdl +++ b/src/TCollection/TCollection_List.cdl @@ -178,11 +178,9 @@ is -- To copy a list, you must explicitly call the assignment operator (operator=). Create(Other : List from TCollection) - returns List from TCollection - is private; + returns List from TCollection; ---Purpose: Creation by copy of existing list. - -- Warning: This constructor prints a warning message. - -- We recommand to use the operator =. + -- We recommend to use the operator =. Assign(me : in out; Other : List from TCollection) ---Purpose: Replace by a copy of . diff --git a/src/TCollection/TCollection_Map.cdl b/src/TCollection/TCollection_Map.cdl index 0aeae7b5a8..78548d57f6 100644 --- a/src/TCollection/TCollection_Map.cdl +++ b/src/TCollection/TCollection_Map.cdl @@ -55,9 +55,6 @@ inherits BasicMap from TCollection -- - TCollection_MapHasher class describes the -- functions required for a Hasher object. -raises - DomainError from Standard - class StdMapNode from TCollection inherits MapNode from TCollection @@ -128,13 +125,9 @@ is -- - and a map iterator to explore the map. - Create(Other : Map from TCollection) returns Map from TCollection + Create(Other : Map from TCollection) returns Map from TCollection; ---Purpose: As copying Map is an expensive operation it is - -- incorrect to do it implicitly. This constructor - -- will raise an error if the Map is not empty. To - -- copy the content of a Map use the Assign method (operator =). - raises DomainError from Standard - is private; + -- not recommended to do it implicitly. Assign(me : in out; Other : Map from TCollection) returns Map from TCollection diff --git a/src/TCollection/TCollection_Map.gxx b/src/TCollection/TCollection_Map.gxx index ba9a066d12..3dc6991bdb 100644 --- a/src/TCollection/TCollection_Map.gxx +++ b/src/TCollection/TCollection_Map.gxx @@ -36,8 +36,12 @@ TCollection_Map::TCollection_Map(const Standard_Integer NbBuckets) : TCollection_Map::TCollection_Map(const TCollection_Map& Other) : TCollection_BasicMap(Other.NbBuckets(),Standard_True) { - if (Other.Extent() != 0) - Standard_DomainError::Raise("TCollection:Copy of Map"); + if (!Other.IsEmpty()) { + ReSize(Other.Extent()); + for (TCollection_MapIterator It(Other); It.More(); It.Next()) { + Add(It.Key()); + } + } } //=======================================================================