home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!uwm.edu!cs.utexas.edu!sun-barr!decwrl!pa.dec.com!brister
- From: brister@decwrl.dec.com (James Brister)
- Newsgroups: comp.lang.c++
- Subject: Re: Reference counting for vectors, (Tony Hansen's book).
- Message-ID: <BRISTER.92Aug14110706@tirade.decwrl.dec.com>
- Date: 14 Aug 92 18:07:06 GMT
- Article-I.D.: tirade.BRISTER.92Aug14110706
- References: <1992Aug14.164719.9719@wuecl.wustl.edu>
- Sender: news@PA.dec.com (News)
- Organization: DEC Western Software Lab
- Lines: 26
- In-Reply-To: abed@venus.wustl.edu's message of Fri, 14 Aug 1992 16:47:19 GMT
-
- On Fri, 14 Aug 1992 16:47:19 GMT, abed@venus.wustl.edu (Abed M. Hammoud) said:
- > I was trying to implement the vector class using the method suggested
- > by tony Hansen. i.e reference counting. the following code is taken
- > from Hansen's book (C++ Answer book). There is some thing that doesn't
- > seems correct.
-
- What's not correct? The fact that modifying one variable causes the other
- to change? If that's not what you want, then this isn't for you, but in the
- case where you're making multiple copies of the array (as paramaters to a
- function, for example), then this scheme is great.
-
- I do remember seeing an article in a magazine a while back about COW (copy
- on write), where the new array (i.e. 'B' here)
-
- > vector B = A;
-
- would release the referrence and make a duplicate of the real data if any
- data was going to be modified. Unfortuantely I can't remember the details
- right now of how it worked, but it didn't seem too tough to do.
-
- (If anyone can refresh my memory that would be good.)
-
- James
- --
- James Brister brister@wsl.pa.dec.com
- DEC Western Software Lab., Palo Alto, CA decwrl!brister
-