From: mheaney@on2.com (Matthew Heaney)
Subject: Re: Missing in Booch: range operations
Date: 8 Nov 2002 13:07:33 -0800
Date: 2002-11-08T21:07:33+00:00 [thread overview]
Message-ID: <1ec946d1.0211081307.24a6c05c@posting.google.com> (raw)
In-Reply-To: 3dcb8eec$0$307$bed64819@news.gradwell.net
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.
next prev parent reply other threads:[~2002-11-08 21:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-08 10:09 Missing in Booch: range operations Victor Porton
2002-11-08 15:01 ` Stephen Leake
2002-11-08 21:07 ` Matthew Heaney [this message]
2002-11-09 13:56 ` Simon Wright
2002-11-13 20:17 ` Matthew Heaney
2002-11-08 21:35 ` Matthew Heaney
2002-11-09 8:24 ` Victor Porton
2002-11-13 20:22 ` Matthew Heaney
2002-11-13 22:28 ` Stephen Leake
2002-11-09 8:46 ` Victor Porton
2002-11-09 14:12 ` Simon Wright
2002-11-09 14:04 ` Simon Wright
2002-11-09 16:12 ` Victor Porton
2002-11-09 20:00 ` Simon Wright
2002-11-11 5:41 ` Victor Porton
2002-11-11 6:39 ` Simon Wright
2002-11-11 7:50 ` Victor Porton
2002-11-13 20:26 ` Matthew Heaney
2002-11-13 22:28 ` Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox