View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0022718 | Community | OCCT:Foundation Classes | public | 2011-09-02 11:46 | 2012-09-18 19:12 |
| Reporter | Assigned To | ||||
| Priority | normal | Severity | feature | ||
| Status | closed | Resolution | duplicate | ||
| Platform | A | OS | L | ||
| Product Version | 6.5.1 | ||||
| Target Version | 6.5.3 | Fixed in Version | 6.5.3 | ||
| Summary | 0022718: NCollection improvement request | ||||
| Description | Post from the Forum - http://www.opencascade.org/org/forum/thread_21658/. "Right now associative containers in NCollection (e.g. NCollection_DataMap) use global functions ::HashCode() and ::IsEqual() to compute hash value for the key and to compare keys. This makes it impossible to use containers requiring different functions for the same key in one compilation unit. An example is use of NCollection_DataMap with TopoDS_Shape as key and IsEqual() using TopoDS_Shape::IsSame(), ignoring orientation and used in most cases and TopoDS_Shape::IsEqual() taking orientation into account. Though I have realized this limitation long ago, I have not reported it until the moment I encountered it (though probably should have). Salome includes SMESHDS_DataMapOfShape.hxx which enforces use of TopoDS_Shape::IsSame() and I need a map of oriented shapes. Obvious suggestion is to extend NCollection templates with additional template arguments, just like standard collections allow (e.g. in STL or Boost). Parameters would default to current behavior to retain source compatibility. Until this is available directly in Open CASCADE, the work-around could be to use boost::unordered_map with provided custom hash and equality functions. This is the way I am going to pursue." | ||||
| Additional information and documentation updates | ABV: Please note that this idea has already been considered (initially proposed by PKV), just it requires some efforts to be completed. See attached couple of mails I exchanged with Roman. ================= 1. Hello Roman, We have tried to implement this idea; the problem was to keep existing ease-to-use by providing default hash functions for typical OCCT data. I do not recall what was a blocking point exactly (likely poor old SUN comiler, dropped some time ago for reasons like that). Thanks for reminder, I shall reiterate on this when I have time. Best Regards, Andrey ============== 2. Hi Andrey, Thanks for paying attention to this. Here is the code I had in mind that would retain default behavior. I believe it is compilable by any decent modern compiler. HTH. Roman The requirement to new extra template parameters - to have defined operator() with signature similar to ::HashCode() and ::IsEqual(). Use of operator() is taken from boost (and STL I believe). The added value of it is that you can use lambda functions to define them. template<typename T> class Hasher { public: Standard_Integer operator() (const T& theKey, const Standard_Integer theUpper) const { return ::HashCode (theKey, theUpper); } }; template<typename T> class IsEqualFunction { public: Standard_Boolean operator() (const T& theKey1, const T& theKey2) const { return ::IsEqual (theKey1, theKey2); } }; template <class TheKeyType, class TheItemType, class TheHasher=Hasher<TheKeyType>, class TheEqualFunction=IsEqualFunction<TheKeyType> > class NCollection_DataMap .... //extra constructor for even further flexibility NCollection_DataMap (const TheHasher& theHasher, const theEqualFunction& theEqualFunction, const Standard_Integer NbBuckets=1, const Handle(NCollection_BaseAllocator)& theAllocator = 0L) : myHasher (theHasher), myEqualFunction (theEqualFunction),... }; Roman ============ | ||||
| Tags | No tags attached. | ||||
| Test case number | |||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2011-09-02 11:46 |
|
New Issue | |
| 2011-09-02 11:46 |
|
Assigned To | => agv |
| 2011-09-21 11:11 | bugmaster | Target Version | 6.5.2 => 6.5.3 |
| 2011-09-22 16:49 |
|
Status | new => assigned |
| 2011-12-01 11:29 |
|
Additional Information Updated | |
| 2011-12-07 07:14 |
|
Target Version | 6.5.3 => 6.5.4 |
| 2012-09-13 13:36 |
|
Status | assigned => closed |
| 2012-09-13 13:37 |
|
Resolution | open => duplicate |
| 2012-09-13 13:37 |
|
Fixed in Version | => 6.5.3 |
| 2012-09-18 19:12 |
|
Target Version | 6.5.4 => 6.5.3 |