Changeset a9c298 in git for Singular/countedref.h
- Timestamp:
- Nov 20, 2013, 4:54:25 PM (10 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- 0de0509972719531e2a4b51ec9fd0e44a66fd2fd
- Parents:
- e4014563a82388c4b39dfa37db24cbe159b24a35
- git-author:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2013-11-20 16:54:25+01:00
- git-committer:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2013-11-20 16:54:42+01:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/countedref.h
re40145 ra9c298 11 11 * 12 12 * @note This works was supported by the "Industrial Algebra" project. 13 * 13 * 14 14 * @par Copyright: 15 15 * (c) 2012 by The Singular Team, see LICENSE file … … 80 80 //} 81 81 82 /// Checking equality 82 /// Checking equality 83 83 bool operator==(const self& rhs) const { return m_ptr == rhs.m_ptr; } 84 84 … … 96 96 count_type count() const { return (*this? m_ptr->ref: 0); } 97 97 void reclaim() { if (*this) ++m_ptr->ref; } 98 void release() { 98 void release() { 99 99 if (*this && (--m_ptr->ref <= 0) && !nondestructive) 100 CountedRefPtr_kill(m_ptr); 100 CountedRefPtr_kill(m_ptr); 101 101 } 102 102 //@} … … 136 136 137 137 template <class PtrType> 138 class CountedRefIndirectPtr: 138 class CountedRefIndirectPtr: 139 139 public RefCounter { 140 140 public: … … 149 149 }; 150 150 151 template <class PtrType> 151 template <class PtrType> 152 152 inline void CountedRefPtr_kill(CountedRefIndirectPtr<PtrType>* pval) { delete pval; } 153 153 … … 184 184 //@{ 185 185 operator bool() const { return operator->(); } 186 self& operator=(const self& rhs) { 186 self& operator=(const self& rhs) { 187 187 m_indirect = rhs.m_indirect; 188 188 return *this; 189 189 } 190 190 self& operator=(ptr_type ptr) { 191 if (!m_indirect) 191 if (!m_indirect) 192 192 m_indirect = new CountedRefIndirectPtr<ptr_type>(ptr); 193 193 else … … 209 209 210 210 /** @class LeftvHelper 211 * This class implements some recurrent code sniplets to be used with 211 * This class implements some recurrent code sniplets to be used with 212 212 * @c leftv and @c idhdl.implements a refernce counter which we can use 213 213 **/ … … 286 286 public LeftvHelper { 287 287 typedef LeftvShallow self; 288 288 289 289 public: 290 290 /// Just allocate (all-zero) @c leftv … … 296 296 297 297 /// Destruct 298 ~LeftvShallow() { 298 ~LeftvShallow() { 299 299 recursivekill(m_data->e); 300 300 omFree(m_data); … … 324 324 /** @class LeftvDeep 325 325 * This class wraps @c leftv by taking into acount memory allocation, destruction 326 * as well as deeply copying of a given @c leftv, i.e. we also take over 326 * as well as deeply copying of a given @c leftv, i.e. we also take over 327 327 * ownership of the @c leftv data. 328 328 * … … 333 333 * @note It invalidats @c leftv on input. 334 334 **/ 335 class LeftvDeep: 335 class LeftvDeep: 336 336 public LeftvHelper { 337 337 typedef LeftvDeep self; … … 349 349 /// Store a deep copy of the data 350 350 /// @ note Occupies the provided @c leftv and invalidates the latter 351 LeftvDeep(leftv data): m_data(cpy(data)) { 352 data->e = NULL; // occupy subexpression 353 if(!isid()) m_data->data=data->CopyD(); 351 LeftvDeep(leftv data): m_data(cpy(data)) { 352 data->e = NULL; // occupy subexpression 353 if(!isid()) m_data->data=data->CopyD(); 354 354 } 355 355 … … 390 390 BOOLEAN brokenid(idhdl context) const { 391 391 assume(isid()); 392 return (context == NULL) || 392 return (context == NULL) || 393 393 ((context != (idhdl) m_data->data) && brokenid(IDNEXT(context))); 394 394 }
Note: See TracChangeset
for help on using the changeset viewer.