home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18270 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.2 KB  |  61 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!spool.mu.edu!sdd.hp.com!network.ucsd.edu!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: Indirect container classes
  5. Message-ID: <1992Dec21.100339.14138@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <1992Dec20.232025.28984@county.oz.au>
  10. Date: Mon, 21 Dec 1992 10:03:39 GMT
  11. Lines: 48
  12.  
  13. In article <1992Dec20.232025.28984@county.oz.au> porum@county.oz.au (Peter Orum) writes:
  14. >Could someone advise on what is the best method of
  15. >having a collection of pointers to large objects. 
  16.  
  17.     I doubt anyone could advise you on the *best* method,
  18. at least without risking a few flamethrowers.
  19.  
  20. >The
  21. >large objects may appear on more than one list, but I
  22. >only want one instance of each object  to be created.
  23. >
  24. >    a)    a list of pointers, eg List<String *>
  25. >    
  26. >    b)    a list class that assumes its  data are pointers
  27. >        eg Indirect_List<String *>
  28. >        
  29. >    c)  use List<String>, but class String is implemented using
  30. >        a pointer to a reference-counted String_rep.
  31. >        
  32. >To  me,  method  a)  is  the easiest to implement but you lose
  33. >the  ability  to  test  for  list  membership  by  content, as
  34. >comparison is on absolute memory addresses.
  35. >
  36. >Method  b)  has  the  disadvantage  of (slightly) complicating
  37. >the   List   class, requiring  overloading  of  the  comparison
  38. >operators, search & copy functions.
  39. >
  40. >Method  c)  complicates the class definition, but means in the
  41. >client  code  I  don't have to decide on which type of List to
  42. >use, nor whether to use pointers or objects.
  43. >
  44. >What do other people do? 
  45. >
  46.  
  47.     c) looks most worth perusing to me. Without reference
  48. counting (a or b), how do you plan to delete the large objects
  49. when they are no longer required? (Or rather, how will
  50. you know when they are no longer required?)
  51.  
  52.     For more techniques purchase Coplien, "Advanced C++
  53. Programming Styles and Idioms".
  54.  
  55.  
  56. -- 
  57. ;----------------------------------------------------------------------
  58.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  59.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  60. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  61.