From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f89c9977a6e4ceda X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-08 13:07:33 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Missing in Booch: range operations Date: 8 Nov 2002 13:07:33 -0800 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0211081307.24a6c05c@posting.google.com> References: <3dcb8eec$0$307$bed64819@news.gradwell.net> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1036789653 9620 127.0.0.1 (8 Nov 2002 21:07:33 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 8 Nov 2002 21:07:33 GMT Xref: archiver1.google.com comp.lang.ada:30612 Date: 2002-11-08T21:07:33+00:00 List-Id: porton@ex-code.com (Victor Porton) wrote in message news:<3dcb8eec$0$307$bed64819@news.gradwell.net>... > Range operations (deleting the range between two iterators, inserting > content of a container or its subrange into a position of another > container etc.) are missing in current Booch. Just to make sure that > these are not forgotten. They were not forgotten in Charles: procedure Delete (Container : in out Container_Type; First, Back : Iterator_Type); The list has splice operations, which are efficient because it only swaps pointers -- there is no copying of elements: procedure Splice (Container : in out Container_Type; Before : in Iterator_Type; Source : in out Container_Type); procedure Splice (Container : in out Container_Type; Before : in Iterator_Type; Source : in out Container_Type; Iterator : in Iterator_Type); procedure Splice (Container : in out Container_Type; Before : in Iterator_Type; Source : in out Container_Type; First : in Iterator_Type; Back : in Iterator_Type); In the case of a vector, you can insert a single element: procedure Insert (Container : in out Container_Type; Before : in Index_Type; New_Item : in Element_Type); If you want to copy the contents of another container into the middle of a vector, you should first open up a "hole" in the vector: procedure Insert_N (Container : in out Container_Type; Before : in Index_Type'Base; Count : in Length_Subtype); and then copy the items from the source into the newly-inserted range (the empty hole) of the vector. http://home.earthlink.net/~matthewjheaney/charles/index.html There is online documention for vector which delves into some of these issues in greater detail: http://home.earthlink.net/~matthewjheaney/charles/charles-vectors-unbounded.html > BTW, these should throw an exception if the begin and the end of the > range are from different containers. The problem is that iterators only know about elements -- they don't know anything about containers. Neither Charles nor the STL attempts to detect this error.