[M3devel] STL algorithms? sort/unique?
mika at async.caltech.edu
mika at async.caltech.edu
Sat Sep 29 22:10:33 CEST 2012
Yeah, OK, you could do this with GENERICs as well, by introducing
a convention. (In fact there is already one, t.iterate.)
I still say it's a bit of a bug. If you have very generic methods that
can take different orders of time, then applying quicksort to a data structure
with high time complexity for those methods won't be very quick at all (except
to type). It can be very misleading unless you really know how everything
hangs together under the covers. I think that's the C/C++ mentality in general...
(BTW I think C++ is a truly impressive programming language. The way you can do OO
programming without using the heap is really impressive. I just don't trust
myself, or anyone I know, to use it right. When even Stroustrup writes in his book,
about certain features, "ask an expert if you want to do this" you have to wonder.)
Jay K writes:
>--_13e6ee6a-034c-469d-aa83-18379d050866_
>Content-Type: text/plain; charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
> > The separation of algorithms from containers sounds a bit like a bug.
>It isn't. It is a leap that allows for far greater code reuse. Efficiently.=
>(You could do it inefficiently with lots of function pointers -- templates =
>allowfor inlinability. C++ beats C for performance here.)
>
>Imagine I have written quicksort.In C++ we have at least the following wort=
>hwhile "array-like" data structures:
>
> The builtin arrays. Like Modula-3 fixed arrays.
>
> Arrays you get with new[]. Like Modula-3 open arrays=2C but they don't ex=
>pose their size.
>
> std::vector<>. Like Modula-3 "sequence" -- a simple growable array. Grows=
> by a constant factor greater than 1 (typically 2)=2C so that long runs of =
>"appends" are amortized cheap.
>
> std::deque<>. More like Modula-3 sequence=2C in that you can amortized ch=
>eap at/remove from the front or the back. I believe this can be implemented=
> as simply an "offset array". Element 0 starts in the middle=2C and wheneve=
>r you grow it=2C you "center" it -- equal gaps at front and back.
>
>Now=2C with the iterator/algorithm separation=2C one quicksort implementati=
>on can be applied to all these types. The input to "quicksort" is "random a=
>ccess iterators"=2C which is very much like a "pointer"=2C but isn't necess=
>arily a pointer. It can be incremented=2C decremented=2C added to an intege=
>r=2C subtracted from another iterator=2C have an integer subtracted from it=
>=2C dereferenced=2C and assigned and compared with other iterators of the s=
>ame type -- all constant time fast operations.
>
>There are "input iterators" which can=2C roughly speaking=2C only be increm=
>ented and dereferenced. They are all some containers can expose and all som=
>e algorithms require -- for example=2C a singly linked list and linear sear=
>ch.
>
>There are "bidirectional iterators" which can=2C roughly speaking=2C only b=
>e incremented and decremented and dereferenced. Doubly linked lists expose =
>these.
>
>There are "output iterators".They are similar to "input".
>
>input streams (cin=2C like stdin) exposes an input iterator.You can copy fr=
>om it.Copy is another simple reusable algorithm.
>
>output streams (cout=2C like stdout) exposes an output iterator.You can cop=
>y to it.
>
>There are many more examples.Of course=2C besides quick sort=2C there is a =
>stable sort.There is finding sequences.There is binary_search.There is uppe=
>r_bound/lower_bound/equal_range which are like binary_search.There is uniqu=
>e.There is partition.Many many more=2C "built in" to the library.That work =
>with multiple "built in" containers=2C and can work with custom containers =
>as well.
>
>I strongly recommend you read up on this stuff.It is really quite illimunin=
>ating. Good stuff.Teaches us how to better factor our code.And to strive fo=
>r better factoring=2C when we find people have invented/discovered such thi=
>ngs.
>
>"Iterators" already do occur in Modula-3 libraries.
>
>All I want is a sorted vector that "closely knows" when it is being written=
> vs. read=2C and when there are a series of writes with no intervening read=
>s=2C it can amortize down the cost of maintaining the ordering.
>
>I hand coded something.It took me a while to get it to work due to stupid s=
>mall details.The result is significantly worse than I would have gotten in =
>C++.Bigger code. Slower code. More copies. More heap allocations.I can elim=
>inate one of the allocations by merging the next step.But in C++ I naturall=
>y wouldn't have had it anyway.Not great.
>
> - Jay
>
>
>> To: jay.krell at cornell.edu
>> CC: mika at async.caltech.edu=3B m3devel at elegosoft.com
>> Subject: Re: [M3devel] STL algorithms? sort/unique?
>> Date: Sat=2C 29 Sep 2012 11:29:48 -0700
>> From: mika at async.caltech.edu
>>=20
>>=20
>> Well that depends on how you maintain the vector=2C no?
>>=20
>> SortedTable uses "treaps" which are supposed to be good data structures.
>> Too new to have made it into Knuth=2C last I checked. The amortized cost
>> of your operations shouldn't be much worse than with your method=2C with
>> the additional benefit that the sorted order is maintained dynamically.
>>=20
>> The separation of algorithms from containers sounds a bit like a bug.
>> You have to be careful so you don't shoot yourself in the foot there!
>> (Sorting a list using an algorithm that randomly accesses elements=2C
>> say...)
>>=20
>> The Modula-3 approach is that you figure out what you want to do=2C pick
>> the ADT you want that provides the minimal set of operations=2C import
>> that interface=2C then instantiate a more carefully chosen implementation
>> of the ADT. The language itself obviously can be coaxed into supporting =
>the
>> algorithm/data structure separation but no one uses it that way as
>> far as I know. (Modula-3 generics are not that well explored=2C actually=
>.
>> I suspect there are many things you can do with them that no one has
>> tried.)
>>=20
>> Mika
>>=20
>> Jay K writes:
>> >--_7877d7e8-cb4a-4989-bdcd-d406e5b1f51f_
>> >Content-Type: text/plain=3B charset=3D"iso-8859-1"
>> >Content-Transfer-Encoding: quoted-printable
>> >
>> >The following is very efficient:
>> >
>> >run through a bunch of records=3D2C picking out one number from some of =
>thema=3D
>> >ppend those numbers to a growing vectorsort the vectorunique the vector
>> >
>> >sequence allows for random access..but only via a function...or maybe an=
> it=3D
>> >erator
>> >
>> >STL has this wonderful separation of algorithms from containers=3D2C via=
> iter=3D
>> >ators.I suspect very few other libraries do.And it could be that most la=
>ngu=3D
>> >ages don't support it.It doesn't appear I can easily sort a sequence=3D2=
>C unl=3D
>> >ess I copy the data out into an array -- gross inefficiency.
>> >
>> >I've hacked something very manual together..and it is taking forever to =
>get=3D
>> > it to work. It turns out I can reasonably well bound the size of the d=
>ata=3D
>> >=3D2C so I'm using an open array...and I have to keep track of my positi=
>on in=3D
>> >stead of using addhi/push_back.Not happy.At some point I might give up a=
>nd =3D
>> >write the backend in C++..at which point I might as well write a C++ fro=
>nte=3D
>> >nd anywa.
>> >
>> >
>> >I absolutely do not want a sorted table and unique upon insert.That is m=
>uch=3D
>> > less efficient.What I'm describing uses temporarily larger working set =
>but=3D
>> > vastly less CPU.An array that gets sorted/uniqued occasionally=3D2C lik=
>e jus=3D
>> >t once.And not ongoing maintainence for every single add.
>> >
>> >
>> > - Jay
>> >
>> >
>> >> To: jay.krell at cornell.edu
>> >> CC: m3devel at elegosoft.com
>> >> Subject: Re: [M3devel] STL algorithms? sort/unique?
>> >> Date: Fri=3D2C 28 Sep 2012 01:04:48 -0700
>> >> From: mika at async.caltech.edu
>> >>=3D20
>> >>=3D20
>> >> BTW I had the same experience when I first started using Modula-3.
>> >> It was painful to jump through all its hoops=3D2C coming from C=3D2C w=
>here yo=3D
>> >u
>> >> can do whatever you want to whatever bits happen to be sloshing around
>> >> your machine. C++ from what I have seen mainly lets you do that to
>> >> more bits in fewer lines of code.
>> >>=3D20
>> >> But after a while I really came to appreciate the value of things like=
> th=3D
>> >e
>> >> language's telling me I'm using the wrong data structure instead of
>> >> just letting me use the same "nice=3D2C terse=3D2C efficient" syntax t=
>o write
>> >> a crappy program :-)
>> >>=3D20
>> >> mika writes:
>> >> >You're using the wrong (abstract) data structure if you want sort and=
> un=3D
>> >ique.
>> >> >
>> >> >A "sequence" is meant to be accessed sequentially...
>> >> >
>> >> >Not knowing precisely what you're doing it sounds like you might want=
> a
>> >> >SortedTable... you can get unique on insert and access it in increasi=
>ng
>> >> >or decreasing order.
>> >> >
>> >> > Mika
>> >> >
>> >> >Jay K writes:
>> >> >>--_d2a02ece-d492-410e-88fb-fb53737d7219_
>> >> >>Content-Type: text/plain=3D3B charset=3D3D"iso-8859-1"
>> >> >>Content-Transfer-Encoding: quoted-printable
>> >> >>
>> >> >> I have an IntSeq.T with a bunch of integers. =3D3D20
>> >> >> What is a good terse efficient idiom for sort and unique? =3D3=
>D20
>> >> >>
>> >> >> In C++ I would say: vector<int> a=3D3D3B a.push_ba=
>ck(..=3D
>> >.)=3D3D3B =3D3D
>> >> >> a.push_back(...)=3D3D3B std::sort(a.begin()=3D3D2C a.e=
>nd())=3D
>> >=3D3D3B =3D3D
>> >> >> a.resize(std::unique(a.begin()=3D3D2C a.end()) - a.begin())=3D3D3B =
> =3D
>> >for (aut=3D3D
>> >> >>o i =3D3D3D a.begin()=3D3D3B i !=3D3D3D a.end()=3D3D3B ++i) {
>> >> >> do stuff with *i }=3D3D20
>> >> >> Nice=3D3D2C terse=3D3D2C efficient. In Modula-3? =3D3D2=
>0
>> >> >>
>> >> >>I know that unique is one of the easiest algorithms to manually writ=
>e i=3D
>> >nlin=3D3D
>> >> >>e=3D3D2Cbut I shouldn't have to.
>> >> >>
>> >> >>(I'm really trying to stay in Modula-3 here=3D3D2C but it is definit=
>ely a=3D
>> > strug=3D3D
>> >> >>gle. :( )
>> >> >>
>> >> >>Thank you=3D3D2C - Jay
>> >> >>
>> >> >> =3D3D
>> >> >>
>> >> >>--_d2a02ece-d492-410e-88fb-fb53737d7219_
>> >> >>Content-Type: text/html=3D3B charset=3D3D"iso-8859-1"
>> >> >>Content-Transfer-Encoding: quoted-printable
>> >> >>
>> >> >><html>
>> >> >><head>
>> >> >><style><!--
>> >> >>.hmmessage P
>> >> >>{
>> >> >>margin:0px=3D3D3B
>> >> >>padding:0px
>> >> >>}
>> >> >>body.hmmessage
>> >> >>{
>> >> >>font-size: 12pt=3D3D3B
>> >> >>font-family:Calibri
>> >> >>}
>> >> >>--></style></head>
>> >> >><body class=3D3D3D'hmmessage'><div dir=3D3D3D'ltr'> =3D3D3B &nbs=
>p=3D3D3B&nb=3D
>> >sp=3D3D3BI have =3D3D
>> >> >>an IntSeq.T with a bunch of integers. =3D3D3B  =3D3D3B =
>=3D3D3B<br=3D
>> >><div><spa=3D3D
>> >> >>n style=3D3D3D"font-size: 12pt=3D3D3B "> =3D3D3B  =3D3D3B</s=
>pan><span s=3D
>> >tyle=3D3D3D"font=3D3D
>> >> >>-size: 12pt=3D3D3B "> =3D3D3B</span>What is a good terse efficie=
>nt idio=3D
>> >m for so=3D3D
>> >> >>rt and unique?<span style=3D3D3D"font-size: 12pt=3D3D3B "> =3D3D=
>3B  =3D
>> >=3D3D3B</span><=3D3D
>> >> >>span style=3D3D3D"font-size: 12pt=3D3D3B "> =3D3D3B</span></div>=
><div><br>=3D
>> ></div><div=3D3D
>> >> >>><br></div><div> =3D3D3B  =3D3D3B In C++ I would say:<span s=
>tyle=3D3D=3D
>> >3D"font-si=3D3D
>> >> >>ze: 12pt=3D3D3B "> =3D3D3B  =3D3D3B</span><span style=3D3D3D=
>"font-size:=3D
>> > 12pt=3D3D3B ">&=3D3D
>> >> >>nbsp=3D3D3B</span></div><div><span style=3D3D3D"font-size: 12pt=3D3D=
>3B ">&nbs=3D
>> >p=3D3D3B  =3D3D
>> >> >>=3D3D3B</span><span style=3D3D3D"font-size: 12pt=3D3D3B "> =3D3D=
>3B</span>ve=3D
>> >ctor<=3D3D3Bin=3D3D
>> >> >>t>=3D3D3B a=3D3D3B<span style=3D3D3D"font-size: 12pt=3D3D3B ">&nbs=
>p=3D3D3B &nbs=3D
>> >p=3D3D3B</span><sp=3D3D
>> >> >>an style=3D3D3D"font-size: 12pt=3D3D3B "> =3D3D3B</span></div><d=
>iv><span =3D
>> >style=3D3D3D"f=3D3D
>> >> >>ont-size: 12pt=3D3D3B "> =3D3D3B  =3D3D3B</span><span style=
>=3D3D3D"font=3D
>> >-size: 12pt=3D3D
>> >> >>=3D3D3B "> =3D3D3B</span>a.push_back(...)=3D3D3B<span style=3D3D=
>3D"font-siz=3D
>> >e: 12pt=3D3D3B "=3D3D
>> >> >>> =3D3D3B  =3D3D3B</span><span style=3D3D3D"font-size: 12pt=
>=3D3D3B ">&n=3D
>> >bsp=3D3D3B</span=3D3D
>> >> >>></div><div><div><span style=3D3D3D"font-size: 12pt=3D3D3B "> =
>=3D3D3B &nb=3D
>> >sp=3D3D3B</spa=3D3D
>> >> >>n><span style=3D3D3D"font-size: 12pt=3D3D3B "> =3D3D3B</span>a.p=
>ush_back(=3D
>> >...)=3D3D3B<sp=3D3D
>> >> >>an style=3D3D3D"font-size: 12pt=3D3D3B "> =3D3D3B  =3D3D3B</=
>span><span =3D
>> >style=3D3D3D"fon=3D3D
>> >> >>t-size: 12pt=3D3D3B "> =3D3D3B</span></div><div><span style=3D3D=
>3D"font-s=3D
>> >ize: 12pt=3D3D
>> >> >>=3D3D3B "> =3D3D3B  =3D3D3B</span><span style=3D3D3D"font-si=
>ze: 12pt=3D3D=3D
>> >3B "> =3D3D3B<=3D3D
>> >> >>/span>std::sort(a.begin()=3D3D2C a.end())=3D3D3B<span style=3D3D3D"f=
>ont-size:=3D
>> > 12pt=3D3D3B "=3D3D
>> >> >>> =3D3D3B  =3D3D3B</span><span style=3D3D3D"font-size: 12pt=
>=3D3D3B ">&n=3D
>> >bsp=3D3D3B</span=3D3D
>> >> >>></div><div><span style=3D3D3D"font-size: 12pt=3D3D3B "> =3D3D3B=
>  =3D3D=3D
>> >3B</span><sp=3D3D
>> >> >>an style=3D3D3D"font-size: 12pt=3D3D3B "> =3D3D3B</span>a.resize=
>(std::uni=3D
>> >que(a.begi=3D3D
>> >> >>n()=3D3D2C a.end()) - a.begin())=3D3D3B<span style=3D3D3D"font-size:=
> 12pt=3D3D3=3D
>> >B "> =3D3D3B=3D3D
>> >> >>  =3D3D3B</span><span style=3D3D3D"font-size: 12pt=3D3D3B ">&nbs=
>p=3D3D3B</s=3D
>> >pan></div><d=3D3D
>> >> >>iv><span style=3D3D3D"font-size: 12pt=3D3D3B "> =3D3D3B  =3D=
>3D3B for (a=3D
>> >uto i =3D3D3D a.=3D3D
>> >> >>begin()=3D3D3B i !=3D3D3D a.end()=3D3D3B ++i)</span></div><div><span=
> style=3D3D=3D
>> >3D"font-size=3D3D
>> >> >>: 12pt=3D3D3B "> =3D3D3B  =3D3D3B {<br> =3D3D3B  =3D=
>3D3B  =3D3D=3D
>> >3B do stuff with=3D3D
>> >> >> *i</span></div><div><span style=3D3D3D"font-size: 12pt=3D3D3B ">&nb=
>sp=3D3D3B=3D
>> >  =3D3D3B =3D3D
>> >> >>}</span></div><div> =3D3D3B</div><div><br></div><div><span style=
>=3D3D3D=3D
>> >"font-si=3D3D
>> >> >>ze: 12pt=3D3D3B "> =3D3D3B  =3D3D3B</span><span style=3D3D3D=
>"font-size:=3D
>> > 12pt=3D3D3B ">&=3D3D
>> >> >>nbsp=3D3D3B</span>Nice=3D3D2C terse=3D3D2C efficient.<span style=3D3=
>D3D"font-si=3D
>> >ze: 12pt=3D3D3B =3D3D
>> >> >>"> =3D3D3B  =3D3D3B</span><span style=3D3D3D"font-size: 12pt=
>=3D3D3B ">&=3D
>> >nbsp=3D3D3B</spa=3D3D
>> >> >>n></div><div><span style=3D3D3D"font-size: 12pt=3D3D3B "> =3D3D3=
>B  =3D
>> >=3D3D3B</span><s=3D3D
>> >> >>pan style=3D3D3D"font-size: 12pt=3D3D3B "> =3D3D3B</span>In Modu=
>la-3?<spa=3D
>> >n style=3D3D3D=3D3D
>> >> >>"font-size: 12pt=3D3D3B "> =3D3D3B  =3D3D3B</span><span styl=
>e=3D3D3D"fo=3D
>> >nt-size: 12p=3D3D
>> >> >>t=3D3D3B "> =3D3D3B</span></div><div><br></div><div><br></div><d=
>iv>I kn=3D
>> >ow that =3D3D
>> >> >>unique is one of the easiest algorithms to manually write inline=3D3=
>D2C</=3D
>> >div><d=3D3D
>> >> >>iv>but I shouldn't have to.</div><div><br></div><div><br></div><div>=
>(I'=3D
>> >m re=3D3D
>> >> >>ally trying to stay in Modula-3 here=3D3D2C but it is definitely a s=
>trugg=3D
>> >le. :(=3D3D
>> >> >> )</div><div><br></div><div><br></div><div>Thank you=3D3D2C</div><di=
>v>&nb=3D
>> >sp=3D3D3B-=3D3D
>> >> >> Jay</div><br><br></div> </div></body>
>> >> >></html>=3D3D
>> >> >>
>> >> >>--_d2a02ece-d492-410e-88fb-fb53737d7219_--
>> > =3D
>> >
>> >--_7877d7e8-cb4a-4989-bdcd-d406e5b1f51f_
>> >Content-Type: text/html=3B charset=3D"iso-8859-1"
>> >Content-Transfer-Encoding: quoted-printable
>> >
>> ><html>
>> ><head>
>> ><style><!--
>> >.hmmessage P
>> >{
>> >margin:0px=3D3B
>> >padding:0px
>> >}
>> >body.hmmessage
>> >{
>> >font-size: 12pt=3D3B
>> >font-family:Calibri
>> >}
>> >--></style></head>
>> ><body class=3D3D'hmmessage'><div dir=3D3D'ltr'><div><span style=3D3D"fon=
>t-size: 1=3D
>> >2pt=3D3B ">The following is very efficient:</span></div><div><br></div><=
>div><=3D
>> >br></div><div>run through a bunch of records=3D2C picking out one number=
> from=3D
>> > some of them</div><div>append those numbers to a growing vector</div><d=
>iv>=3D
>> >sort the vector</div><div>unique the vector</div><div><br></div><div><br=
>></=3D
>> >div><div>sequence allows for random access..but only via a function...</=
>div=3D
>> >><div>or maybe an iterator</div><div><br></div><div><br></div><div>STL h=
>as =3D
>> >this wonderful separation of algorithms from containers=3D2C via iterato=
>rs.</=3D
>> >div><div>I suspect very few other libraries do.</div><div>And it could b=
>e t=3D
>> >hat most languages don't support it.</div><div>It doesn't appear I can e=
>asi=3D
>> >ly sort a sequence=3D2C unless I copy the data out into an array -- gros=
>s ine=3D
>> >fficiency.</div><div><br></div><div><br></div><div>I've hacked something=
> ve=3D
>> >ry manual together..and it is taking forever to get it to work.</div><di=
>v>&=3D
>> >nbsp=3D3B It turns out I can reasonably well bound the size of the data=
>=3D2C so=3D
>> > I'm using an open array...and I have to keep track of my position inste=
>ad =3D
>> >of using addhi/push_back.</div><div>Not happy.</div><div>At some point I=
> mi=3D
>> >ght give up and write the backend in C++..at which point I might as well=
> wr=3D
>> >ite a C++ frontend anywa.</div><div><br></div><div><br></div><div><br></=
>div=3D
>> >><div>I absolutely do not want a sorted table and unique upon insert.</d=
>iv>=3D
>> ><div>That is much less efficient.</div><div>What I'm describing uses tem=
>por=3D
>> >arily larger working set but vastly less CPU.</div><div>An array that ge=
>ts =3D
>> >sorted/uniqued occasionally=3D2C like just once.</div><div>And not ongoi=
>ng ma=3D
>> >intainence for every single add.</div><div><br></div><div><br></div><div=
>><b=3D
>> >r></div><div> =3D3B- Jay</div><div><br><br><br><div><div id=3D3D"Sky=
>DrivePl=3D
>> >aceholder"></div>>=3D3B To: jay.krell at cornell.edu<br>>=3D3B CC: m3de=
>vel at ele=3D
>> >gosoft.com<br>>=3D3B Subject: Re: [M3devel] STL algorithms? sort/uniqu=
>e?<br=3D
>> >>>=3D3B Date: Fri=3D2C 28 Sep 2012 01:04:48 -0700<br>>=3D3B From: mi=
>ka at async.=3D
>> >caltech.edu<br>>=3D3B <br>>=3D3B <br>>=3D3B BTW I had the same exp=
>erience w=3D
>> >hen I first started using Modula-3.<br>>=3D3B It was painful to jump t=
>hroug=3D
>> >h all its hoops=3D2C coming from C=3D2C where you<br>>=3D3B can do wha=
>tever you=3D
>> > want to whatever bits happen to be sloshing around<br>>=3D3B your mac=
>hine.=3D
>> > C++ from what I have seen mainly lets you do that to<br>>=3D3B more =
>bits =3D
>> >in fewer lines of code.<br>>=3D3B <br>>=3D3B But after a while I rea=
>lly cam=3D
>> >e to appreciate the value of things like the<br>>=3D3B language's tell=
>ing m=3D
>> >e I'm using the wrong data structure instead of<br>>=3D3B just letting=
> me u=3D
>> >se the same "nice=3D2C terse=3D2C efficient" syntax to write<br>>=3D3B=
> a crappy=3D
>> > program :-)<br>>=3D3B <br>>=3D3B mika writes:<br>>=3D3B >=3D3BY=
>ou're using=3D
>> > the wrong (abstract) data structure if you want sort and unique.<br>>=
>=3D3B=3D
>> > >=3D3B<br>>=3D3B >=3D3BA "sequence" is meant to be accessed seque=
>ntially..=3D
>> >.<br>>=3D3B >=3D3B<br>>=3D3B >=3D3BNot knowing precisely what yo=
>u're doing =3D
>> >it sounds like you might want a<br>>=3D3B >=3D3BSortedTable... you c=
>an get =3D
>> >unique on insert and access it in increasing<br>>=3D3B >=3D3Bor decr=
>easing =3D
>> >order.<br>>=3D3B >=3D3B<br>>=3D3B >=3D3B Mika<br>>=3D3B >=
>=3D3B<br>>=3D3B=3D
>> > >=3D3BJay K writes:<br>>=3D3B >=3D3B>=3D3B--_d2a02ece-d492-410e=
>-88fb-fb537=3D
>> >37d7219_<br>>=3D3B >=3D3B>=3D3BContent-Type: text/plain=3D3B chars=
>et=3D3D"iso-8=3D
>> >859-1"<br>>=3D3B >=3D3B>=3D3BContent-Transfer-Encoding: quoted-pri=
>ntable<br=3D
>> >>>=3D3B >=3D3B>=3D3B<br>>=3D3B >=3D3B>=3D3B I have an Int=
>Seq.T with a bu=3D
>> >nch of integers. =3D3D20<br>>=3D3B >=3D3B>=3D3B What is a goo=
>d terse eff=3D
>> >icient idiom for sort and unique? =3D3D20<br>>=3D3B >=3D3B>=3D3B=
><br>>=3D3B =3D
>> >>=3D3B>=3D3B In C++ I would say: vector<=3D3Bint>=3D3B=
> a=3D3D3B =3D
>> > a.push_back(...)=3D3D3B =3D3D<br>>=3D3B >=3D3B>=3D3B a.p=
>ush_back(...)=3D
>> >=3D3D3B std::sort(a.begin()=3D3D2C a.end())=3D3D3B =3D3D<br=
>>>=3D3B >=3D
>> >=3D3B>=3D3B a.resize(std::unique(a.begin()=3D3D2C a.end()) - a.begin()=
>)=3D3D3B =3D
>> > for (aut=3D3D<br>>=3D3B >=3D3B>=3D3Bo i =3D3D3D a.begin()=3D3=
>D3B i !=3D3D3D a.=3D
>> >end()=3D3D3B ++i) {<br>>=3D3B >=3D3B>=3D3B do stuff with *=
>i }=3D3D20=3D
>> ><br>>=3D3B >=3D3B>=3D3B Nice=3D3D2C terse=3D3D2C efficient. =
> In Modula=3D
>> >-3? =3D3D20<br>>=3D3B >=3D3B>=3D3B<br>>=3D3B >=3D3B>=3D3BI=
> know that unique=3D
>> > is one of the easiest algorithms to manually write inlin=3D3D<br>>=3D=
>3B >=3D
>> >=3D3B>=3D3Be=3D3D2Cbut I shouldn't have to.<br>>=3D3B >=3D3B>=3D=
>3B<br>>=3D3B &g=3D
>> >t=3D3B>=3D3B(I'm really trying to stay in Modula-3 here=3D3D2C but it =
>is defini=3D
>> >tely a strug=3D3D<br>>=3D3B >=3D3B>=3D3Bgle. :( )<br>>=3D3B >=
>=3D3B>=3D3B<br>&=3D
>> >gt=3D3B >=3D3B>=3D3BThank you=3D3D2C - Jay<br>>=3D3B >=3D3B>=
>=3D3B<br>>=3D3B >=3D
>> >=3D3B>=3D3B =3D3D<br>>=3D3B >=3D3B>=3D3B<br>>=3D3B =
>>=3D3B>=3D3B--_d2=3D
>> >a02ece-d492-410e-88fb-fb53737d7219_<br>>=3D3B >=3D3B>=3D3BContent-=
>Type: tex=3D
>> >t/html=3D3B charset=3D3D"iso-8859-1"<br>>=3D3B >=3D3B>=3D3BContent=
>-Transfer-Enc=3D
>> >oding: quoted-printable<br>>=3D3B >=3D3B>=3D3B<br>>=3D3B >=3D3=
>B>=3D3B<=3D3B=3D
>> >html>=3D3B<br>>=3D3B >=3D3B>=3D3B<=3D3Bhead>=3D3B<br>>=3D3=
>B >=3D3B>=3D3B<=3D
>> >=3D3Bstyle>=3D3B<=3D3B!--<br>>=3D3B >=3D3B>=3D3B.hmmessage P<b=
>r>>=3D3B >=3D3B=3D
>> >>=3D3B{<br>>=3D3B >=3D3B>=3D3Bmargin:0px=3D3D3B<br>>=3D3B >=
>=3D3B>=3D3Bpadding=3D
>> >:0px<br>>=3D3B >=3D3B>=3D3B}<br>>=3D3B >=3D3B>=3D3Bbody.hmme=
>ssage<br>>=3D3B=3D
>> > >=3D3B>=3D3B{<br>>=3D3B >=3D3B>=3D3Bfont-size: 12pt=3D3D3B<br=
>>>=3D3B >=3D3B&=3D
>> >gt=3D3Bfont-family:Calibri<br>>=3D3B >=3D3B>=3D3B}<br>>=3D3B >=
>=3D3B>=3D3B--&g=3D
>> >t=3D3B<=3D3B/style>=3D3B<=3D3B/head>=3D3B<br>>=3D3B >=3D3B&g=
>t=3D3B<=3D3Bbody cl=3D
>> >ass=3D3D3D'hmmessage'>=3D3B<=3D3Bdiv dir=3D3D3D'ltr'>=3D3B&=3D3=
>Bnbsp=3D3D3B &=3D
>> >=3D3Bnbsp=3D3D3B&=3D3Bnbsp=3D3D3BI have =3D3D<br>>=3D3B >=3D3B>=
>=3D3Ban IntSeq.T wi=3D
>> >th a bunch of integers.&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B&=3D3=
>Bnbsp=3D3D3B<=3D
>> >=3D3Bbr>=3D3B<=3D3Bdiv>=3D3B<=3D3Bspa=3D3D<br>>=3D3B >=3D3B&=
>gt=3D3Bn style=3D3D3D"f=3D
>> >ont-size: 12pt=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B=
><=3D3B/span>=3D
>> >=3D3B<=3D3Bspan style=3D3D3D"font=3D3D<br>>=3D3B >=3D3B>=3D3B-si=
>ze: 12pt=3D3D3B "&g=3D
>> >t=3D3B&=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3BWhat is a good terse effi=
>cient idiom f=3D
>> >or so=3D3D<br>>=3D3B >=3D3B>=3D3Brt and unique?<=3D3Bspan style=
>=3D3D3D"font-siz=3D
>> >e: 12pt=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B<=3D3=
>B/span>=3D3B<=3D
>> >=3D3B=3D3D<br>>=3D3B >=3D3B>=3D3Bspan style=3D3D3D"font-size: 12pt=
>=3D3D3B ">=3D3B&a=3D
>> >mp=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3B<=3D3B/div>=3D3B<=3D3Bdiv&g=
>t=3D3B<=3D3Bbr>=3D
>> >=3D3B<=3D3B/div>=3D3B<=3D3Bdiv=3D3D<br>>=3D3B >=3D3B>=3D3B&g=
>t=3D3B<=3D3Bbr>=3D3B&=3D
>> >lt=3D3B/div>=3D3B<=3D3Bdiv>=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=
>=3D3D3B In C++ I wo=3D
>> >uld say:<=3D3Bspan style=3D3D3D"font-si=3D3D<br>>=3D3B >=3D3B>=
>=3D3Bze: 12pt=3D3D3=3D
>> >B ">=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3=
>B<=3D3Bspan style=3D
>> >=3D3D3D"font-size: 12pt=3D3D3B ">=3D3B&=3D3B=3D3D<br>>=3D3B >=
>=3D3B>=3D3Bnbsp=3D3D3=3D
>> >B<=3D3B/span>=3D3B<=3D3B/div>=3D3B<=3D3Bdiv>=3D3B<=3D3Bspa=
>n style=3D3D3D"font=3D
>> >-size: 12pt=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D<br>&=
>gt=3D3B >=3D3B>=3D
>> >=3D3B=3D3D3B<=3D3B/span>=3D3B<=3D3Bspan style=3D3D3D"font-size: 12=
>pt=3D3D3B ">=3D3B=3D
>> >&=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3Bvector&=3D3Blt=3D3D3Bin=3D3D=
><br>>=3D3B >=3D3B=3D
>> >>=3D3Bt&=3D3Bgt=3D3D3B a=3D3D3B<=3D3Bspan style=3D3D3D"font-size:=
> 12pt=3D3D3B ">=3D
>> >=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3B<=
>=3D3Bsp=3D3D<br>>=3D3B =3D
>> >>=3D3B>=3D3Ban style=3D3D3D"font-size: 12pt=3D3D3B ">=3D3B&=3D3=
>Bnbsp=3D3D3B<=3D
>> >=3D3B/span>=3D3B<=3D3B/div>=3D3B<=3D3Bdiv>=3D3B<=3D3Bspan st=
>yle=3D3D3D"f=3D3D<br>=3D
>> >>=3D3B >=3D3B>=3D3Bont-size: 12pt=3D3D3B ">=3D3B&=3D3Bnbsp=3D=
>3D3B &=3D3Bnbsp=3D
>> >=3D3D3B<=3D3B/span>=3D3B<=3D3Bspan style=3D3D3D"font-size: 12pt=3D=
>3D<br>>=3D3B &g=3D
>> >t=3D3B>=3D3B=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3B=
>a.push_back(...)=3D3D=3D
>> >3B<=3D3Bspan style=3D3D3D"font-size: 12pt=3D3D3B "=3D3D<br>>=3D3B &g=
>t=3D3B>=3D3B>=3D
>> >=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3B<=
>=3D3Bspan style=3D3D3D"=3D
>> >font-size: 12pt=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B<=3D3B/span=3D3D<b=
>r>>=3D3B >=3D3B=3D
>> >>=3D3B>=3D3B<=3D3B/div>=3D3B<=3D3Bdiv>=3D3B<=3D3Bdiv>=3D=
>3B<=3D3Bspan style=3D
>> >=3D3D3D"font-size: 12pt=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnb=
>sp=3D3D3B<=3D3B/s=3D
>> >pa=3D3D<br>>=3D3B >=3D3B>=3D3Bn>=3D3B<=3D3Bspan style=3D3D3D"f=
>ont-size: 12pt=3D3D=3D
>> >3B ">=3D3B&=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3Ba.push_back(...)=3D=
>3D3B<=3D3Bsp=3D3D=3D
>> ><br>>=3D3B >=3D3B>=3D3Ban style=3D3D3D"font-size: 12pt=3D3D3B ">=
>=3D3B&=3D3Bnbs=3D
>> >p=3D3D3B &=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3B<=3D3Bspan style=3D3=
>D3D"fon=3D3D<br>>=3D
>> >=3D3B >=3D3B>=3D3Bt-size: 12pt=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B&=
>lt=3D3B/span>=3D3B&=3D
>> >lt=3D3B/div>=3D3B<=3D3Bdiv>=3D3B<=3D3Bspan style=3D3D3D"font-siz=
>e: 12pt=3D3D<br>&=3D
>> >gt=3D3B >=3D3B>=3D3B=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bn=
>bsp=3D3D3B<=3D3B/span=3D
>> >>=3D3B<=3D3Bspan style=3D3D3D"font-size: 12pt=3D3D3B ">=3D3B&=
>=3D3Bnbsp=3D3D3B<=3D
>> >=3D3B=3D3D<br>>=3D3B >=3D3B>=3D3B/span>=3D3Bstd::sort(a.begin()=
>=3D3D2C a.end())=3D
>> >=3D3D3B<=3D3Bspan style=3D3D3D"font-size: 12pt=3D3D3B "=3D3D<br>>=3D=
>3B >=3D3B>=3D3B=3D
>> >>=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3B&l=
>t=3D3Bspan style=3D3D=3D
>> >3D"font-size: 12pt=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B<=3D3B/span=3D3=
>D<br>>=3D3B >=3D
>> >=3D3B>=3D3B>=3D3B<=3D3B/div>=3D3B<=3D3Bdiv>=3D3B<=3D3Bspan=
> style=3D3D3D"font-si=3D
>> >ze: 12pt=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B<=3D=
>3B/span>=3D3B<=3D
>> >=3D3Bsp=3D3D<br>>=3D3B >=3D3B>=3D3Ban style=3D3D3D"font-size: 12pt=
>=3D3D3B ">=3D3B&a=3D
>> >mp=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3Ba.resize(std::unique(a.begi=3D3D<=
>br>>=3D3B >=3D
>> >=3D3B>=3D3Bn()=3D3D2C a.end()) - a.begin())=3D3D3B<=3D3Bspan style=
>=3D3D3D"font-size=3D
>> >: 12pt=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B=3D3D<br>>=3D3B >=3D3B>=
>=3D3B &=3D3Bnbsp=3D
>> >=3D3D3B<=3D3B/span>=3D3B<=3D3Bspan style=3D3D3D"font-size: 12pt=3D=
>3D3B ">=3D3B&am=3D
>> >p=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3B<=3D3B/div>=3D3B<=3D3Bd=3D3D=
><br>>=3D3B >=3D3B&g=3D
>> >t=3D3Biv>=3D3B<=3D3Bspan style=3D3D3D"font-size: 12pt=3D3D3B ">=3D=
>3B&=3D3Bnbsp=3D
>> >=3D3D3B &=3D3Bnbsp=3D3D3B for (auto i =3D3D3D a.=3D3D<br>>=3D3B >=
>=3D3B>=3D3Bbegin(=3D
>> >)=3D3D3B i !=3D3D3D a.end()=3D3D3B ++i)<=3D3B/span>=3D3B<=3D3B/div=
>>=3D3B<=3D3Bdiv=3D
>> >>=3D3B<=3D3Bspan style=3D3D3D"font-size=3D3D<br>>=3D3B >=3D3B>=
>=3D3B: 12pt=3D3D3B =3D
>> >">=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B {<=3D3Bbr>=3D3B&a=
>mp=3D3Bnbsp=3D3D3B &a=3D
>> >mp=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B do stuff with=3D3D<br>>=3D3B &=
>gt=3D3B>=3D3B *i&=3D
>> >lt=3D3B/span>=3D3B<=3D3B/div>=3D3B<=3D3Bdiv>=3D3B<=3D3Bspan =
>style=3D3D3D"font-s=3D
>> >ize: 12pt=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B =3D3=
>D<br>>=3D3B >=3D
>> >=3D3B>=3D3B}<=3D3B/span>=3D3B<=3D3B/div>=3D3B<=3D3Bdiv>=3D=
>3B&=3D3Bnbsp=3D3D3B&=3D
>> >lt=3D3B/div>=3D3B<=3D3Bdiv>=3D3B<=3D3Bbr>=3D3B<=3D3B/div>=
>=3D3B<=3D3Bdiv>=3D3B=3D
>> ><=3D3Bspan style=3D3D3D"font-si=3D3D<br>>=3D3B >=3D3B>=3D3Bze: 1=
>2pt=3D3D3B ">=3D
>> >=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3B<=
>=3D3Bspan style=3D3D3D"=3D
>> >font-size: 12pt=3D3D3B ">=3D3B&=3D3B=3D3D<br>>=3D3B >=3D3B>=
>=3D3Bnbsp=3D3D3B<=3D
>> >=3D3B/span>=3D3BNice=3D3D2C terse=3D3D2C efficient.<=3D3Bspan style=
>=3D3D3D"font-siz=3D
>> >e: 12pt=3D3D3B =3D3D<br>>=3D3B >=3D3B>=3D3B">=3D3B&=3D3Bnbsp=
>=3D3D3B &=3D3Bnbsp=3D
>> >=3D3D3B<=3D3B/span>=3D3B<=3D3Bspan style=3D3D3D"font-size: 12pt=3D=
>3D3B ">=3D3B&am=3D
>> >p=3D3Bnbsp=3D3D3B<=3D3B/spa=3D3D<br>>=3D3B >=3D3B>=3D3Bn>=3D3B=
><=3D3B/div>=3D3B<=3D
>> >=3D3Bdiv>=3D3B<=3D3Bspan style=3D3D3D"font-size: 12pt=3D3D3B ">=3D=
>3B&=3D3Bnbsp=3D
>> >=3D3D3B &=3D3Bnbsp=3D3D3B<=3D3B/span>=3D3B<=3D3Bs=3D3D<br>>=
>=3D3B >=3D3B>=3D3Bpan=3D
>> > style=3D3D3D"font-size: 12pt=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B<=3D=
>3B/span>=3D3BIn=3D
>> > Modula-3?<=3D3Bspan style=3D3D3D=3D3D<br>>=3D3B >=3D3B>=3D3B"fo=
>nt-size: 12pt=3D
>> >=3D3D3B ">=3D3B&=3D3Bnbsp=3D3D3B &=3D3Bnbsp=3D3D3B<=3D3B/span&=
>gt=3D3B<=3D3Bspan s=3D
>> >tyle=3D3D3D"font-size: 12p=3D3D<br>>=3D3B >=3D3B>=3D3Bt=3D3D3B "&g=
>t=3D3B&=3D3Bnbsp=3D
>> >=3D3D3B<=3D3B/span>=3D3B<=3D3B/div>=3D3B<=3D3Bdiv>=3D3B<=
>=3D3Bbr>=3D3B<=3D3B/d=3D
>> >iv>=3D3B<=3D3Bdiv>=3D3B<=3D3Bbr>=3D3B<=3D3B/div>=3D3B<=
>=3D3Bdiv>=3D3BI know =3D
>> >that =3D3D<br>>=3D3B >=3D3B>=3D3Bunique is one of the easiest algo=
>rithms to m=3D
>> >anually write inline=3D3D2C<=3D3B/div>=3D3B<=3D3Bd=3D3D<br>>=3D3=
>B >=3D3B>=3D3Bi=3D
>> >v>=3D3Bbut I shouldn't have to.<=3D3B/div>=3D3B<=3D3Bdiv>=3D3B=
><=3D3Bbr>=3D
>> >=3D3B<=3D3B/div>=3D3B<=3D3Bdiv>=3D3B<=3D3Bbr>=3D3B<=3D3B/d=
>iv>=3D3B<=3D3Bdiv&g=3D
>> >t=3D3B(I'm re=3D3D<br>>=3D3B >=3D3B>=3D3Bally trying to stay in Mo=
>dula-3 here=3D
>> >=3D3D2C but it is definitely a struggle. :(=3D3D<br>>=3D3B >=3D3B>=
>=3D3B )<=3D3B=3D
>> >/div>=3D3B<=3D3Bdiv>=3D3B<=3D3Bbr>=3D3B<=3D3B/div>=3D3B<=
>=3D3Bdiv>=3D3B<=3D
>> >=3D3Bbr>=3D3B<=3D3B/div>=3D3B<=3D3Bdiv>=3D3BThank you=3D3D2C&l=
>t=3D3B/div>=3D3B<=3D
>> >=3D3Bdiv>=3D3B&=3D3Bnbsp=3D3D3B-=3D3D<br>>=3D3B >=3D3B>=3D3B =
>Jay<=3D3B/div>=3D3B=3D
>> ><=3D3Bbr>=3D3B<=3D3Bbr>=3D3B<=3D3B/div>=3D3B <=
>=3D3B/div>=3D3B<=3D
>> >=3D3B/body>=3D3B<br>>=3D3B >=3D3B>=3D3B<=3D3B/html>=3D3B=3D3=
>D<br>>=3D3B >=3D3B&=3D
>> >gt=3D3B<br>>=3D3B >=3D3B>=3D3B--_d2a02ece-d492-410e-88fb-fb53737d7=
>219_--<br><=3D
>> >/div></div> </div></body>
>> ></html>=3D
>> >
>> >--_7877d7e8-cb4a-4989-bdcd-d406e5b1f51f_--
> =
>
>--_13e6ee6a-034c-469d-aa83-18379d050866_
>Content-Type: text/html; charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
><html>
><head>
><style><!--
>.hmmessage P
>{
>margin:0px=3B
>padding:0px
>}
>body.hmmessage
>{
>font-size: 12pt=3B
>font-family:Calibri
>}
>--></style></head>
><body class=3D'hmmessage'><div dir=3D'ltr'><pre style=3D"line-height: 21.81=
>818199157715px=3B white-space: normal=3B font-size: 15.454545021057129px=3B=
> background-color: rgb(255=2C 255=2C 255)=3B "> =3B>=3B The separatio=
>n of algorithms from containers sounds a bit like a bug.</pre><div><br></di=
>v>It isn't. It is a leap that allows for far greater code reuse. Efficientl=
>y.<div>(You could do it inefficiently with lots of function pointers -- tem=
>plates allow</div><div>for inlinability. C++ beats C for performance here.)=
></div><div><div><br></div><div><br></div><div>Imagine I have written quicks=
>ort.</div><div>In C++ we have at least the following worthwhile "array-like=
>" data structures:</div><div><br></div><div><br></div><div> =3B The bui=
>ltin arrays. Like Modula-3 fixed arrays.</div><div><br></div><div><br></div=
>><div> =3B Arrays you get with new[]. Like Modula-3 open arrays=2C but =
>they don't expose their size.</div><div><br></div><div><br></div><div> =
>=3B std::vector<=3B>=3B. Like Modula-3 "sequence" -- a simple growable =
>array. Grows by a constant factor greater than 1 (typically 2)=2C so that l=
>ong runs of "appends" are amortized cheap.</div><div><br></div><div><br></d=
>iv><div> =3B std::deque<=3B>=3B. More like Modula-3 sequence=2C in =
>that you can amortized cheap at/remove from the front or the back. I believ=
>e this can be implemented as simply an "offset array". Element 0 starts in =
>the middle=2C and whenever you grow it=2C you "center" it -- equal gaps at =
>front and back.</div><div><br></div><div><br></div><div>Now=2C with the ite=
>rator/algorithm separation=2C one quicksort implementation can be applied t=
>o all these types. The input to "quicksort" is "random access iterators"=2C=
> which is very much like a "pointer"=2C but isn't necessarily a pointer. It=
> can be incremented=2C decremented=2C added to an integer=2C subtracted fro=
>m another iterator=2C have an integer subtracted from it=2C dereferenced=2C=
> and assigned and compared with other iterators of the same type -- all con=
>stant time fast operations.</div><div><br></div><div><br>There are "input i=
>terators" which can=2C roughly speaking=2C only be incremented and derefere=
>nced. They are all some containers can expose and all some algorithms requi=
>re -- for example=2C a singly linked list and linear search.</div><div><br>=
></div><div><br></div><div>There are "bidirectional iterators" which can=2C =
>roughly speaking=2C only be incremented and decremented and dereferenced. D=
>oubly linked lists expose these.</div><div><br></div><div><br></div><div>Th=
>ere are "output iterators".</div><div>They are similar to "input".</div><di=
>v><br></div><div><br></div><div>input streams (cin=2C like stdin) exposes a=
>n input iterator.</div><div>You can copy from it.</div><div>Copy is another=
> simple reusable algorithm.</div><div><br></div><div><br></div><div>output =
>streams (cout=2C like stdout) exposes an output iterator.</div><div>You can=
> copy to it.</div><div><br></div><div><br></div><div>There are many more ex=
>amples.</div><div>Of course=2C besides quick sort=2C there is a stable sort=
>.</div><div>There is finding sequences.</div><div>There is binary_search.</=
>div><div>There is upper_bound/lower_bound/equal_range which are like binary=
>_search.</div><div>There is unique.</div><div>There is partition.</div><div=
>>Many many more=2C "built in" to the library.</div><div>That work with mult=
>iple "built in" containers=2C and can work with custom containers as well.<=
>/div><div><br></div><div><br></div><div>I strongly recommend you read up on=
> this stuff.</div><div>It is really quite illimuninating. Good stuff.</div>=
><div>Teaches us how to better factor our code.</div><div>And to strive for =
>better factoring=2C when we find people have invented/discovered such thing=
>s.</div><div><br></div><div><br></div><div>"Iterators" already do occur in =
>Modula-3 libraries.</div><div><br></div><div><br></div><div>All I want is a=
> sorted vector that "closely knows" when it is being written vs. read=2C an=
>d when there are a series of writes with no intervening reads=2C it can amo=
>rtize down the cost of maintaining the ordering.</div><div><br></div><div><=
>br></div><div>I hand coded something.</div><div>It took me a while to get i=
>t to work due to stupid small details.</div><div>The result is significantl=
>y worse than I would have gotten in C++.</div><div>Bigger code. Slower code=
>. More copies. More heap allocations.</div><div>I can eliminate one of the =
>allocations by merging the next step.</div><div>But in C++ I naturally woul=
>dn't have had it anyway.</div><div>Not great.</div><div><br></div><div><br>=
></div><div> =3B- Jay<br><br><br><div><div id=3D"SkyDrivePlaceholder"></=
>div>>=3B To: jay.krell at cornell.edu<br>>=3B CC: mika at async.caltech.edu=
>=3B m3devel at elegosoft.com<br>>=3B Subject: Re: [M3devel] STL algorithms? =
>sort/unique?<br>>=3B Date: Sat=2C 29 Sep 2012 11:29:48 -0700<br>>=3B Fr=
>om: mika at async.caltech.edu<br>>=3B <br>>=3B <br>>=3B Well that depend=
>s on how you maintain the vector=2C no?<br>>=3B <br>>=3B SortedTable us=
>es "treaps" which are supposed to be good data structures.<br>>=3B Too ne=
>w to have made it into Knuth=2C last I checked. The amortized cost<br>>=
>=3B of your operations shouldn't be much worse than with your method=2C wit=
>h<br>>=3B the additional benefit that the sorted order is maintained dyna=
>mically.<br>>=3B <br>>=3B The separation of algorithms from containers =
>sounds a bit like a bug.<br>>=3B You have to be careful so you don't shoo=
>t yourself in the foot there!<br>>=3B (Sorting a list using an algorithm =
>that randomly accesses elements=2C<br>>=3B say...)<br>>=3B <br>>=3B T=
>he Modula-3 approach is that you figure out what you want to do=2C pick<br>=
>>=3B the ADT you want that provides the minimal set of operations=2C impo=
>rt<br>>=3B that interface=2C then instantiate a more carefully chosen imp=
>lementation<br>>=3B of the ADT. The language itself obviously can be coa=
>xed into supporting the<br>>=3B algorithm/data structure separation but n=
>o one uses it that way as<br>>=3B far as I know. (Modula-3 generics are =
>not that well explored=2C actually.<br>>=3B I suspect there are many thin=
>gs you can do with them that no one has<br>>=3B tried.)<br>>=3B <br>>=
>=3B Mika<br>>=3B <br>>=3B Jay K writes:<br>>=3B >=3B--_7877d7e=
>8-cb4a-4989-bdcd-d406e5b1f51f_<br>>=3B >=3BContent-Type: text/plain=3B =
>charset=3D"iso-8859-1"<br>>=3B >=3BContent-Transfer-Encoding: quoted-pr=
>intable<br>>=3B >=3B<br>>=3B >=3BThe following is very efficient:<b=
>r>>=3B >=3B<br>>=3B >=3Brun through a bunch of records=3D2C picking=
> out one number from some of thema=3D<br>>=3B >=3Bppend those numbers t=
>o a growing vectorsort the vectorunique the vector<br>>=3B >=3B<br>>=
>=3B >=3Bsequence allows for random access..but only via a function...or m=
>aybe an it=3D<br>>=3B >=3Berator<br>>=3B >=3B<br>>=3B >=3BSTL h=
>as this wonderful separation of algorithms from containers=3D2C via iter=3D=
><br>>=3B >=3Bators.I suspect very few other libraries do.And it could b=
>e that most langu=3D<br>>=3B >=3Bages don't support it.It doesn't appea=
>r I can easily sort a sequence=3D2C unl=3D<br>>=3B >=3Bess I copy the d=
>ata out into an array -- gross inefficiency.<br>>=3B >=3B<br>>=3B >=
>=3BI've hacked something very manual together..and it is taking forever to =
>get=3D<br>>=3B >=3B it to work. It turns out I can reasonably well bou=
>nd the size of the data=3D<br>>=3B >=3B=3D2C so I'm using an open array=
>...and I have to keep track of my position in=3D<br>>=3B >=3Bstead of u=
>sing addhi/push_back.Not happy.At some point I might give up and =3D<br>>=
>=3B >=3Bwrite the backend in C++..at which point I might as well write a =
>C++ fronte=3D<br>>=3B >=3Bnd anywa.<br>>=3B >=3B<br>>=3B >=3B<b=
>r>>=3B >=3BI absolutely do not want a sorted table and unique upon inse=
>rt.That is much=3D<br>>=3B >=3B less efficient.What I'm describing uses=
> temporarily larger working set but=3D<br>>=3B >=3B vastly less CPU.An =
>array that gets sorted/uniqued occasionally=3D2C like jus=3D<br>>=3B >=
>=3Bt once.And not ongoing maintainence for every single add.<br>>=3B >=
>=3B<br>>=3B >=3B<br>>=3B >=3B - Jay<br>>=3B >=3B<br>>=3B >=
>=3B<br>>=3B >=3B>=3B To: jay.krell at cornell.edu<br>>=3B >=3B>=3B=
> CC: m3devel at elegosoft.com<br>>=3B >=3B>=3B Subject: Re: [M3devel] ST=
>L algorithms? sort/unique?<br>>=3B >=3B>=3B Date: Fri=3D2C 28 Sep 201=
>2 01:04:48 -0700<br>>=3B >=3B>=3B From: mika at async.caltech.edu<br>>=
>=3B >=3B>=3B=3D20<br>>=3B >=3B>=3B=3D20<br>>=3B >=3B>=3B BT=
>W I had the same experience when I first started using Modula-3.<br>>=3B =
>>=3B>=3B It was painful to jump through all its hoops=3D2C coming from =
>C=3D2C where yo=3D<br>>=3B >=3Bu<br>>=3B >=3B>=3B can do whatever=
> you want to whatever bits happen to be sloshing around<br>>=3B >=3B>=
>=3B your machine. C++ from what I have seen mainly lets you do that to<br>=
>>=3B >=3B>=3B more bits in fewer lines of code.<br>>=3B >=3B>=
>=3B=3D20<br>>=3B >=3B>=3B But after a while I really came to apprecia=
>te the value of things like th=3D<br>>=3B >=3Be<br>>=3B >=3B>=3B =
>language's telling me I'm using the wrong data structure instead of<br>>=
>=3B >=3B>=3B just letting me use the same "nice=3D2C terse=3D2C efficie=
>nt" syntax to write<br>>=3B >=3B>=3B a crappy program :-)<br>>=3B &=
>gt=3B>=3B=3D20<br>>=3B >=3B>=3B mika writes:<br>>=3B >=3B>=3B=
> >=3BYou're using the wrong (abstract) data structure if you want sort an=
>d un=3D<br>>=3B >=3Bique.<br>>=3B >=3B>=3B >=3B<br>>=3B >=
>=3B>=3B >=3BA "sequence" is meant to be accessed sequentially...<br>>=
>=3B >=3B>=3B >=3B<br>>=3B >=3B>=3B >=3BNot knowing precisely =
>what you're doing it sounds like you might want a<br>>=3B >=3B>=3B &g=
>t=3BSortedTable... you can get unique on insert and access it in increasing=
><br>>=3B >=3B>=3B >=3Bor decreasing order.<br>>=3B >=3B>=3B &=
>gt=3B<br>>=3B >=3B>=3B >=3B Mika<br>>=3B >=3B>=3B >=3B<b=
>r>>=3B >=3B>=3B >=3BJay K writes:<br>>=3B >=3B>=3B >=3B>=
>=3B--_d2a02ece-d492-410e-88fb-fb53737d7219_<br>>=3B >=3B>=3B >=3B&g=
>t=3BContent-Type: text/plain=3D3B charset=3D3D"iso-8859-1"<br>>=3B >=3B=
>>=3B >=3B>=3BContent-Transfer-Encoding: quoted-printable<br>>=3B &g=
>t=3B>=3B >=3B>=3B<br>>=3B >=3B>=3B >=3B>=3B I have an In=
>tSeq.T with a bunch of integers. =3D3D20<br>>=3B >=3B>=3B >=3B>=
>=3B What is a good terse efficient idiom for sort and unique? =3D3D20<=
>br>>=3B >=3B>=3B >=3B>=3B<br>>=3B >=3B>=3B >=3B>=3B =
>In C++ I would say: vector<=3Bint>=3B a=3D3D3B a.push_bac=
>k(..=3D<br>>=3B >=3B.)=3D3D3B =3D3D<br>>=3B >=3B>=3B >=3B>=3B=
> a.push_back(...)=3D3D3B std::sort(a.begin()=3D3D2C a.end())=
>=3D<br>>=3B >=3B=3D3D3B =3D3D<br>>=3B >=3B>=3B >=3B>=3B=
> a.resize(std::unique(a.begin()=3D3D2C a.end()) - a.begin())=3D3D3B =
>=3D<br>>=3B >=3Bfor (aut=3D3D<br>>=3B >=3B>=3B >=3B>=3Bo i =
>=3D3D3D a.begin()=3D3D3B i !=3D3D3D a.end()=3D3D3B ++i) {<br>>=3B >=
>=3B>=3B >=3B>=3B do stuff with *i }=3D3D20<br>>=3B >=3B&g=
>t=3B >=3B>=3B Nice=3D3D2C terse=3D3D2C efficient. In Modula-3=
>? =3D3D20<br>>=3B >=3B>=3B >=3B>=3B<br>>=3B >=3B>=3B >=
>=3B>=3BI know that unique is one of the easiest algorithms to manually wr=
>ite i=3D<br>>=3B >=3Bnlin=3D3D<br>>=3B >=3B>=3B >=3B>=3Be=3D3=
>D2Cbut I shouldn't have to.<br>>=3B >=3B>=3B >=3B>=3B<br>>=3B &=
>gt=3B>=3B >=3B>=3B(I'm really trying to stay in Modula-3 here=3D3D2C =
>but it is definitely a=3D<br>>=3B >=3B strug=3D3D<br>>=3B >=3B>=
>=3B >=3B>=3Bgle. :( )<br>>=3B >=3B>=3B >=3B>=3B<br>>=3B >=
>=3B>=3B >=3B>=3BThank you=3D3D2C - Jay<br>>=3B >=3B>=3B >=3B&=
>gt=3B<br>>=3B >=3B>=3B >=3B>=3B =3D3D<br>>=3B >=3B=
>>=3B >=3B>=3B<br>>=3B >=3B>=3B >=3B>=3B--_d2a02ece-d492-410=
>e-88fb-fb53737d7219_<br>>=3B >=3B>=3B >=3B>=3BContent-Type: text/=
>html=3D3B charset=3D3D"iso-8859-1"<br>>=3B >=3B>=3B >=3B>=3BConte=
>nt-Transfer-Encoding: quoted-printable<br>>=3B >=3B>=3B >=3B>=3B<=
>br>>=3B >=3B>=3B >=3B>=3B<=3Bhtml>=3B<br>>=3B >=3B>=3B =
>>=3B>=3B<=3Bhead>=3B<br>>=3B >=3B>=3B >=3B>=3B<=3Bstyle=
>>=3B<=3B!--<br>>=3B >=3B>=3B >=3B>=3B.hmmessage P<br>>=3B &=
>gt=3B>=3B >=3B>=3B{<br>>=3B >=3B>=3B >=3B>=3Bmargin:0px=3D3=
>D3B<br>>=3B >=3B>=3B >=3B>=3Bpadding:0px<br>>=3B >=3B>=3B &=
>gt=3B>=3B}<br>>=3B >=3B>=3B >=3B>=3Bbody.hmmessage<br>>=3B &g=
>t=3B>=3B >=3B>=3B{<br>>=3B >=3B>=3B >=3B>=3Bfont-size: 12pt=
>=3D3D3B<br>>=3B >=3B>=3B >=3B>=3Bfont-family:Calibri<br>>=3B &g=
>t=3B>=3B >=3B>=3B}<br>>=3B >=3B>=3B >=3B>=3B-->=3B<=3B/=
>style>=3B<=3B/head>=3B<br>>=3B >=3B>=3B >=3B>=3B<=3Bbody =
>class=3D3D3D'hmmessage'>=3B<=3Bdiv dir=3D3D3D'ltr'>=3B&=3Bnbsp=3D3=
>D3B &=3Bnbsp=3D3D3B&=3Bnb=3D<br>>=3B >=3Bsp=3D3D3BI have =3D3D<br=
>>>=3B >=3B>=3B >=3B>=3Ban IntSeq.T with a bunch of integers.&=
>=3Bnbsp=3D3D3B &=3Bnbsp=3D3D3B&=3Bnbsp=3D3D3B<=3Bbr=3D<br>>=3B &g=
>t=3B>=3B<=3Bdiv>=3B<=3Bspa=3D3D<br>>=3B >=3B>=3B >=3B>=3B=
>n style=3D3D3D"font-size: 12pt=3D3D3B ">=3B&=3Bnbsp=3D3D3B &=3Bnbsp=
>=3D3D3B<=3B/span>=3B<=3Bspan s=3D<br>>=3B >=3Btyle=3D3D3D"font=3D=
>3D<br>>=3B >=3B>=3B >=3B>=3B-size: 12pt=3D3D3B ">=3B&=3Bnbsp=
>=3D3D3B<=3B/span>=3BWhat is a good terse efficient idio=3D<br>>=3B &g=
>t=3Bm for so=3D3D<br>>=3B >=3B>=3B >=3B>=3Brt and unique?<=3Bsp=
>an style=3D3D3D"font-size: 12pt=3D3D3B ">=3B&=3Bnbsp=3D3D3B &=3Bnbs=
>p=3D<br>>=3B >=3B=3D3D3B<=3B/span>=3B<=3B=3D3D<br>>=3B >=3B&g=
>t=3B >=3B>=3Bspan style=3D3D3D"font-size: 12pt=3D3D3B ">=3B&=3Bnbs=
>p=3D3D3B<=3B/span>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=3B=3D<b=
>r>>=3B >=3B<=3B/div>=3B<=3Bdiv=3D3D<br>>=3B >=3B>=3B >=3B=
>>=3B>=3B<=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3B&=3Bnbsp=3D3D3B=
> &=3Bnbsp=3D3D3B In C++ I would say:<=3Bspan style=3D3D=3D<br>>=3B &=
>gt=3B3D"font-si=3D3D<br>>=3B >=3B>=3B >=3B>=3Bze: 12pt=3D3D3B "&g=
>t=3B&=3Bnbsp=3D3D3B &=3Bnbsp=3D3D3B<=3B/span>=3B<=3Bspan style=
>=3D3D3D"font-size:=3D<br>>=3B >=3B 12pt=3D3D3B ">=3B&=3B=3D3D<br>&=
>gt=3B >=3B>=3B >=3B>=3Bnbsp=3D3D3B<=3B/span>=3B<=3B/div>=3B=
><=3Bdiv>=3B<=3Bspan style=3D3D3D"font-size: 12pt=3D3D3B ">=3B&=
>=3Bnbs=3D<br>>=3B >=3Bp=3D3D3B &=3Bnbsp=3D3D<br>>=3B >=3B>=3B =
>>=3B>=3B=3D3D3B<=3B/span>=3B<=3Bspan style=3D3D3D"font-size: 12pt=
>=3D3D3B ">=3B&=3Bnbsp=3D3D3B<=3B/span>=3Bve=3D<br>>=3B >=3Bcto=
>r&=3Blt=3D3D3Bin=3D3D<br>>=3B >=3B>=3B >=3B>=3Bt&=3Bgt=3D3D=
>3B a=3D3D3B<=3Bspan style=3D3D3D"font-size: 12pt=3D3D3B ">=3B&=3Bnbs=
>p=3D3D3B &=3Bnbs=3D<br>>=3B >=3Bp=3D3D3B<=3B/span>=3B<=3Bsp=3D=
>3D<br>>=3B >=3B>=3B >=3B>=3Ban style=3D3D3D"font-size: 12pt=3D3D3=
>B ">=3B&=3Bnbsp=3D3D3B<=3B/span>=3B<=3B/div>=3B<=3Bdiv>=3B=
><=3Bspan =3D<br>>=3B >=3Bstyle=3D3D3D"f=3D3D<br>>=3B >=3B>=3B &=
>gt=3B>=3Bont-size: 12pt=3D3D3B ">=3B&=3Bnbsp=3D3D3B &=3Bnbsp=3D3D=
>3B<=3B/span>=3B<=3Bspan style=3D3D3D"font=3D<br>>=3B >=3B-size: 1=
>2pt=3D3D<br>>=3B >=3B>=3B >=3B>=3B=3D3D3B ">=3B&=3Bnbsp=3D3D=
>3B<=3B/span>=3Ba.push_back(...)=3D3D3B<=3Bspan style=3D3D3D"font-siz=
>=3D<br>>=3B >=3Be: 12pt=3D3D3B "=3D3D<br>>=3B >=3B>=3B >=3B>=
>=3B>=3B&=3Bnbsp=3D3D3B &=3Bnbsp=3D3D3B<=3B/span>=3B<=3Bspan s=
>tyle=3D3D3D"font-size: 12pt=3D3D3B ">=3B&=3Bn=3D<br>>=3B >=3Bbsp=
>=3D3D3B<=3B/span=3D3D<br>>=3B >=3B>=3B >=3B>=3B>=3B<=3B/div=
>>=3B<=3Bdiv>=3B<=3Bdiv>=3B<=3Bspan style=3D3D3D"font-size: 12pt=
>=3D3D3B ">=3B&=3Bnbsp=3D3D3B &=3Bnb=3D<br>>=3B >=3Bsp=3D3D3B<=
>=3B/spa=3D3D<br>>=3B >=3B>=3B >=3B>=3Bn>=3B<=3Bspan style=3D3=
>D3D"font-size: 12pt=3D3D3B ">=3B&=3Bnbsp=3D3D3B<=3B/span>=3Ba.push=
>_back(=3D<br>>=3B >=3B...)=3D3D3B<=3Bsp=3D3D<br>>=3B >=3B>=3B &=
>gt=3B>=3Ban style=3D3D3D"font-size: 12pt=3D3D3B ">=3B&=3Bnbsp=3D3D3B=
> &=3Bnbsp=3D3D3B<=3B/span>=3B<=3Bspan =3D<br>>=3B >=3Bstyle=3D=
>3D3D"fon=3D3D<br>>=3B >=3B>=3B >=3B>=3Bt-size: 12pt=3D3D3B ">=
>=3B&=3Bnbsp=3D3D3B<=3B/span>=3B<=3B/div>=3B<=3Bdiv>=3B<=3B=
>span style=3D3D3D"font-s=3D<br>>=3B >=3Bize: 12pt=3D3D<br>>=3B >=3B=
>>=3B >=3B>=3B=3D3D3B ">=3B&=3Bnbsp=3D3D3B &=3Bnbsp=3D3D3B<=
>=3B/span>=3B<=3Bspan style=3D3D3D"font-size: 12pt=3D3D=3D<br>>=3B >=
>=3B3B ">=3B&=3Bnbsp=3D3D3B<=3B=3D3D<br>>=3B >=3B>=3B >=3B>=
>=3B/span>=3Bstd::sort(a.begin()=3D3D2C a.end())=3D3D3B<=3Bspan style=3D=
>3D3D"font-size:=3D<br>>=3B >=3B 12pt=3D3D3B "=3D3D<br>>=3B >=3B>=
>=3B >=3B>=3B>=3B&=3Bnbsp=3D3D3B &=3Bnbsp=3D3D3B<=3B/span>=
>=3B<=3Bspan style=3D3D3D"font-size: 12pt=3D3D3B ">=3B&=3Bn=3D<br>>=
>=3B >=3Bbsp=3D3D3B<=3B/span=3D3D<br>>=3B >=3B>=3B >=3B>=3B>=
>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bspan style=3D3D3D"font-size: 12pt=
>=3D3D3B ">=3B&=3Bnbsp=3D3D3B &=3Bnbsp=3D3D=3D<br>>=3B >=3B3B<=
>=3B/span>=3B<=3Bsp=3D3D<br>>=3B >=3B>=3B >=3B>=3Ban style=3D3=
>D3D"font-size: 12pt=3D3D3B ">=3B&=3Bnbsp=3D3D3B<=3B/span>=3Ba.resi=
>ze(std::uni=3D<br>>=3B >=3Bque(a.begi=3D3D<br>>=3B >=3B>=3B >=
>=3B>=3Bn()=3D3D2C a.end()) - a.begin())=3D3D3B<=3Bspan style=3D3D3D"fon=
>t-size: 12pt=3D3D3=3D<br>>=3B >=3BB ">=3B&=3Bnbsp=3D3D3B=3D3D<br>&=
>gt=3B >=3B>=3B >=3B>=3B &=3Bnbsp=3D3D3B<=3B/span>=3B<=3Bsp=
>an style=3D3D3D"font-size: 12pt=3D3D3B ">=3B&=3Bnbsp=3D3D3B<=3B/s=3D=
><br>>=3B >=3Bpan>=3B<=3B/div>=3B<=3Bd=3D3D<br>>=3B >=3B>=
>=3B >=3B>=3Biv>=3B<=3Bspan style=3D3D3D"font-size: 12pt=3D3D3B ">=
>=3B&=3Bnbsp=3D3D3B &=3Bnbsp=3D3D3B for (a=3D<br>>=3B >=3Buto i =
>=3D3D3D a.=3D3D<br>>=3B >=3B>=3B >=3B>=3Bbegin()=3D3D3B i !=3D3D3=
>D a.end()=3D3D3B ++i)<=3B/span>=3B<=3B/div>=3B<=3Bdiv>=3B<=3B=
>span style=3D3D=3D<br>>=3B >=3B3D"font-size=3D3D<br>>=3B >=3B>=3B=
> >=3B>=3B: 12pt=3D3D3B ">=3B&=3Bnbsp=3D3D3B &=3Bnbsp=3D3D3B {&l=
>t=3Bbr>=3B&=3Bnbsp=3D3D3B &=3Bnbsp=3D3D3B &=3Bnbsp=3D3D=3D<br>&g=
>t=3B >=3B3B do stuff with=3D3D<br>>=3B >=3B>=3B >=3B>=3B *i<=
>=3B/span>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bspan style=3D3D3D"font-s=
>ize: 12pt=3D3D3B ">=3B&=3Bnbsp=3D3D3B=3D<br>>=3B >=3B &=3Bnbsp=
>=3D3D3B =3D3D<br>>=3B >=3B>=3B >=3B>=3B}<=3B/span>=3B<=3B/d=
>iv>=3B<=3Bdiv>=3B&=3Bnbsp=3D3D3B<=3B/div>=3B<=3Bdiv>=3B<=
>=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bspan style=3D3D3D=3D<br>>=
>=3B >=3B"font-si=3D3D<br>>=3B >=3B>=3B >=3B>=3Bze: 12pt=3D3D3B =
>">=3B&=3Bnbsp=3D3D3B &=3Bnbsp=3D3D3B<=3B/span>=3B<=3Bspan sty=
>le=3D3D3D"font-size:=3D<br>>=3B >=3B 12pt=3D3D3B ">=3B&=3B=3D3D<br=
>>>=3B >=3B>=3B >=3B>=3Bnbsp=3D3D3B<=3B/span>=3BNice=3D3D2C te=
>rse=3D3D2C efficient.<=3Bspan style=3D3D3D"font-si=3D<br>>=3B >=3Bze:=
> 12pt=3D3D3B =3D3D<br>>=3B >=3B>=3B >=3B>=3B">=3B&=3Bnbsp=3D=
>3D3B &=3Bnbsp=3D3D3B<=3B/span>=3B<=3Bspan style=3D3D3D"font-size: =
>12pt=3D3D3B ">=3B&=3B=3D<br>>=3B >=3Bnbsp=3D3D3B<=3B/spa=3D3D<br=
>>>=3B >=3B>=3B >=3B>=3Bn>=3B<=3B/div>=3B<=3Bdiv>=3B<=
>=3Bspan style=3D3D3D"font-size: 12pt=3D3D3B ">=3B&=3Bnbsp=3D3D3B &=
>=3Bnbsp=3D<br>>=3B >=3B=3D3D3B<=3B/span>=3B<=3Bs=3D3D<br>>=3B &=
>gt=3B>=3B >=3B>=3Bpan style=3D3D3D"font-size: 12pt=3D3D3B ">=3B&=
>=3Bnbsp=3D3D3B<=3B/span>=3BIn Modula-3?<=3Bspa=3D<br>>=3B >=3Bn s=
>tyle=3D3D3D=3D3D<br>>=3B >=3B>=3B >=3B>=3B"font-size: 12pt=3D3D3B=
> ">=3B&=3Bnbsp=3D3D3B &=3Bnbsp=3D3D3B<=3B/span>=3B<=3Bspan st=
>yle=3D3D3D"fo=3D<br>>=3B >=3Bnt-size: 12p=3D3D<br>>=3B >=3B>=3B &=
>gt=3B>=3Bt=3D3D3B ">=3B&=3Bnbsp=3D3D3B<=3B/span>=3B<=3B/div>=
>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=
>=3B<=3B/div>=3B<=3Bdiv>=3BI kn=3D<br>>=3B >=3Bow that =3D3D<br>=
>>=3B >=3B>=3B >=3B>=3Bunique is one of the easiest algorithms to =
>manually write inline=3D3D2C<=3B/=3D<br>>=3B >=3Bdiv>=3B<=3Bd=3D3=
>D<br>>=3B >=3B>=3B >=3B>=3Biv>=3Bbut I shouldn't have to.<=3B=
>/div>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3B<=
>=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3B(I'=3D<br>>=3B >=3Bm re=3D3D<=
>br>>=3B >=3B>=3B >=3B>=3Bally trying to stay in Modula-3 here=3D3=
>D2C but it is definitely a strugg=3D<br>>=3B >=3Ble. :(=3D3D<br>>=3B =
>>=3B>=3B >=3B>=3B )<=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=3B<=
>=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3BTh=
>ank you=3D3D2C<=3B/div>=3B<=3Bdiv>=3B&=3Bnb=3D<br>>=3B >=3Bs=
>p=3D3D3B-=3D3D<br>>=3B >=3B>=3B >=3B>=3B Jay<=3B/div>=3B<=
>=3Bbr>=3B<=3Bbr>=3B<=3B/div>=3B <=3B/div>=3B<=3B=
>/body>=3B<br>>=3B >=3B>=3B >=3B>=3B<=3B/html>=3B=3D3D<br>&g=
>t=3B >=3B>=3B >=3B>=3B<br>>=3B >=3B>=3B >=3B>=3B--_d2a02e=
>ce-d492-410e-88fb-fb53737d7219_--<br>>=3B >=3B =3D<br>>=3B=
> >=3B<br>>=3B >=3B--_7877d7e8-cb4a-4989-bdcd-d406e5b1f51f_<br>>=3B =
>>=3BContent-Type: text/html=3B charset=3D"iso-8859-1"<br>>=3B >=3BCon=
>tent-Transfer-Encoding: quoted-printable<br>>=3B >=3B<br>>=3B >=3B&=
>lt=3Bhtml>=3B<br>>=3B >=3B<=3Bhead>=3B<br>>=3B >=3B<=3Bstyl=
>e>=3B<=3B!--<br>>=3B >=3B.hmmessage P<br>>=3B >=3B{<br>>=3B &=
>gt=3Bmargin:0px=3D3B<br>>=3B >=3Bpadding:0px<br>>=3B >=3B}<br>>=
>=3B >=3Bbody.hmmessage<br>>=3B >=3B{<br>>=3B >=3Bfont-size: 12pt=
>=3D3B<br>>=3B >=3Bfont-family:Calibri<br>>=3B >=3B}<br>>=3B >=
>=3B-->=3B<=3B/style>=3B<=3B/head>=3B<br>>=3B >=3B<=3Bbody c=
>lass=3D3D'hmmessage'>=3B<=3Bdiv dir=3D3D'ltr'>=3B<=3Bdiv>=3B<=
>=3Bspan style=3D3D"font-size: 1=3D<br>>=3B >=3B2pt=3D3B ">=3BThe foll=
>owing is very efficient:<=3B/span>=3B<=3B/div>=3B<=3Bdiv>=3B<=
>=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3B<=3B=3D<br>>=3B >=3Bbr>=
>=3B<=3B/div>=3B<=3Bdiv>=3Brun through a bunch of records=3D2C picki=
>ng out one number from=3D<br>>=3B >=3B some of them<=3B/div>=3B<=
>=3Bdiv>=3Bappend those numbers to a growing vector<=3B/div>=3B<=3Bd=
>iv>=3B=3D<br>>=3B >=3Bsort the vector<=3B/div>=3B<=3Bdiv>=3Bu=
>nique the vector<=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/div>=
>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/=3D<br>>=3B >=3Bdiv>=3B<=3Bd=
>iv>=3Bsequence allows for random access..but only via a function...<=3B=
>/div=3D<br>>=3B >=3B>=3B<=3Bdiv>=3Bor maybe an iterator<=3B/div=
>>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bbr&=
>gt=3B<=3B/div>=3B<=3Bdiv>=3BSTL has =3D<br>>=3B >=3Bthis wonder=
>ful separation of algorithms from containers=3D2C via iterators.<=3B/=3D<=
>br>>=3B >=3Bdiv>=3B<=3Bdiv>=3BI suspect very few other libraries =
>do.<=3B/div>=3B<=3Bdiv>=3BAnd it could be t=3D<br>>=3B >=3Bhat =
>most languages don't support it.<=3B/div>=3B<=3Bdiv>=3BIt doesn't a=
>ppear I can easi=3D<br>>=3B >=3Bly sort a sequence=3D2C unless I copy t=
>he data out into an array -- gross ine=3D<br>>=3B >=3Bfficiency.<=3B/=
>div>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3B<=3B=
>br>=3B<=3B/div>=3B<=3Bdiv>=3BI've hacked something ve=3D<br>>=
>=3B >=3Bry manual together..and it is taking forever to get it to work.&l=
>t=3B/div>=3B<=3Bdiv>=3B&=3B=3D<br>>=3B >=3Bnbsp=3D3B It turns =
>out I can reasonably well bound the size of the data=3D2C so=3D<br>>=3B &=
>gt=3B I'm using an open array...and I have to keep track of my position ins=
>tead =3D<br>>=3B >=3Bof using addhi/push_back.<=3B/div>=3B<=3Bdiv=
>>=3BNot happy.<=3B/div>=3B<=3Bdiv>=3BAt some point I mi=3D<br>>=
>=3B >=3Bght give up and write the backend in C++..at which point I might =
>as well wr=3D<br>>=3B >=3Bite a C++ frontend anywa.<=3B/div>=3B<=
>=3Bdiv>=3B<=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=3B<=
>=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/div=3D<br>>=3B >=3B>=
>=3B<=3Bdiv>=3BI absolutely do not want a sorted table and unique upon i=
>nsert.<=3B/div>=3B=3D<br>>=3B >=3B<=3Bdiv>=3BThat is much less =
>efficient.<=3B/div>=3B<=3Bdiv>=3BWhat I'm describing uses tempor=3D=
><br>>=3B >=3Barily larger working set but vastly less CPU.<=3B/div>=
>=3B<=3Bdiv>=3BAn array that gets =3D<br>>=3B >=3Bsorted/uniqued occ=
>asionally=3D2C like just once.<=3B/div>=3B<=3Bdiv>=3BAnd not ongoin=
>g ma=3D<br>>=3B >=3Bintainence for every single add.<=3B/div>=3B<=
>=3Bdiv>=3B<=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=3B<=
>=3B/div>=3B<=3Bdiv>=3B<=3Bb=3D<br>>=3B >=3Br>=3B<=3B/div>=
>=3B<=3Bdiv>=3B&=3Bnbsp=3D3B- Jay<=3B/div>=3B<=3Bdiv>=3B<=
>=3Bbr>=3B<=3Bbr>=3B<=3Bbr>=3B<=3Bdiv>=3B<=3Bdiv id=3D3D"Sky=
>DrivePl=3D<br>>=3B >=3Baceholder">=3B<=3B/div>=3B&=3Bgt=3D3B T=
>o: jay.krell at cornell.edu<=3Bbr>=3B&=3Bgt=3D3B CC: m3devel at ele=3D<br>=
>>=3B >=3Bgosoft.com<=3Bbr>=3B&=3Bgt=3D3B Subject: Re: [M3devel] =
>STL algorithms? sort/unique?<=3Bbr=3D<br>>=3B >=3B>=3B&=3Bgt=3D3=
>B Date: Fri=3D2C 28 Sep 2012 01:04:48 -0700<=3Bbr>=3B&=3Bgt=3D3B Fro=
>m: mika at async.=3D<br>>=3B >=3Bcaltech.edu<=3Bbr>=3B&=3Bgt=3D3B &=
>lt=3Bbr>=3B&=3Bgt=3D3B <=3Bbr>=3B&=3Bgt=3D3B BTW I had the same=
> experience w=3D<br>>=3B >=3Bhen I first started using Modula-3.<=3Bb=
>r>=3B&=3Bgt=3D3B It was painful to jump throug=3D<br>>=3B >=3Bh al=
>l its hoops=3D2C coming from C=3D2C where you<=3Bbr>=3B&=3Bgt=3D3B c=
>an do whatever you=3D<br>>=3B >=3B want to whatever bits happen to be s=
>loshing around<=3Bbr>=3B&=3Bgt=3D3B your machine.=3D<br>>=3B >=
>=3B C++ from what I have seen mainly lets you do that to<=3Bbr>=3B&=
>=3Bgt=3D3B more bits =3D<br>>=3B >=3Bin fewer lines of code.<=3Bbr>=
>=3B&=3Bgt=3D3B <=3Bbr>=3B&=3Bgt=3D3B But after a while I really c=
>am=3D<br>>=3B >=3Be to appreciate the value of things like the<=3Bbr&=
>gt=3B&=3Bgt=3D3B language's telling m=3D<br>>=3B >=3Be I'm using the=
> wrong data structure instead of<=3Bbr>=3B&=3Bgt=3D3B just letting m=
>e u=3D<br>>=3B >=3Bse the same "nice=3D2C terse=3D2C efficient" syntax =
>to write<=3Bbr>=3B&=3Bgt=3D3B a crappy=3D<br>>=3B >=3B program :=
>-)<=3Bbr>=3B&=3Bgt=3D3B <=3Bbr>=3B&=3Bgt=3D3B mika writes:<=
>=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=3D3BYou're using=3D<br>>=3B >=3B th=
>e wrong (abstract) data structure if you want sort and unique.<=3Bbr>=
>=3B&=3Bgt=3D3B=3D<br>>=3B >=3B &=3Bgt=3D3B<=3Bbr>=3B&=3Bgt=
>=3D3B &=3Bgt=3D3BA "sequence" is meant to be accessed sequentially..=3D<=
>br>>=3B >=3B.<=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=3D3B<=3Bbr>=3B&=
>amp=3Bgt=3D3B &=3Bgt=3D3BNot knowing precisely what you're doing =3D<br>=
>>=3B >=3Bit sounds like you might want a<=3Bbr>=3B&=3Bgt=3D3B &a=
>mp=3Bgt=3D3BSortedTable... you can get =3D<br>>=3B >=3Bunique on insert=
> and access it in increasing<=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=3D3Bor d=
>ecreasing =3D<br>>=3B >=3Border.<=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=
>=3D3B<=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=3D3B Mika<=3Bbr>=3B&=
>=3Bgt=3D3B &=3Bgt=3D3B<=3Bbr>=3B&=3Bgt=3D3B=3D<br>>=3B >=3B &=
>amp=3Bgt=3D3BJay K writes:<=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=3D3B&=
>=3Bgt=3D3B--_d2a02ece-d492-410e-88fb-fb537=3D<br>>=3B >=3B37d7219_<=
>=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=3D3B&=3Bgt=3D3BContent-Type: text/pl=
>ain=3D3B charset=3D3D"iso-8=3D<br>>=3B >=3B859-1"<=3Bbr>=3B&=3Bg=
>t=3D3B &=3Bgt=3D3B&=3Bgt=3D3BContent-Transfer-Encoding: quoted-printa=
>ble<=3Bbr=3D<br>>=3B >=3B>=3B&=3Bgt=3D3B &=3Bgt=3D3B&=3Bgt=
>=3D3B<=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=3D3B&=3Bgt=3D3B I have an=
> IntSeq.T with a bu=3D<br>>=3B >=3Bnch of integers. =3D3D20<=3Bbr&g=
>t=3B&=3Bgt=3D3B &=3Bgt=3D3B&=3Bgt=3D3B What is a good terse eff=
>=3D<br>>=3B >=3Bicient idiom for sort and unique? =3D3D20<=3Bbr>=
>=3B&=3Bgt=3D3B &=3Bgt=3D3B&=3Bgt=3D3B<=3Bbr>=3B&=3Bgt=3D3B =
>=3D<br>>=3B >=3B&=3Bgt=3D3B&=3Bgt=3D3B In C++ I would say: =
> vector&=3Blt=3D3Bint&=3Bgt=3D3B a=3D3D3B =3D<br>>=3B >=3B =
> a.push_back(...)=3D3D3B =3D3D<=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=3D3B=
>&=3Bgt=3D3B a.push_back(...)=3D<br>>=3B >=3B=3D3D3B std=
>::sort(a.begin()=3D3D2C a.end())=3D3D3B =3D3D<=3Bbr>=3B&=3Bgt=
>=3D3B &=3Bgt=3D<br>>=3B >=3B=3D3B&=3Bgt=3D3B a.resize(std::unique=
>(a.begin()=3D3D2C a.end()) - a.begin())=3D3D3B =3D<br>>=3B >=3B f=
>or (aut=3D3D<=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=3D3B&=3Bgt=3D3Bo i =
>=3D3D3D a.begin()=3D3D3B i !=3D3D3D a.=3D<br>>=3B >=3Bend()=3D3D3B ++i)=
> {<=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=3D3B&=3Bgt=3D3B do stuf=
>f with *i }=3D3D20=3D<br>>=3B >=3B<=3Bbr>=3B&=3Bgt=3D3B &=
>=3Bgt=3D3B&=3Bgt=3D3B Nice=3D3D2C terse=3D3D2C efficient. In M=
>odula=3D<br>>=3B >=3B-3? =3D3D20<=3Bbr>=3B&=3Bgt=3D3B &=3Bg=
>t=3D3B&=3Bgt=3D3B<=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=3D3B&=3Bgt=3D=
>3BI know that unique=3D<br>>=3B >=3B is one of the easiest algorithms t=
>o manually write inlin=3D3D<=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=3D<br>>=
>=3B >=3B=3D3B&=3Bgt=3D3Be=3D3D2Cbut I shouldn't have to.<=3Bbr>=3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Blt=3D3Bdiv&=3Bgt=3D3B&=
>amp=3Blt=3D3Bbr&=3Bgt=3D3B&=3Blt=3D3B/div&=3Bgt=3D3B&=3Blt=3D3B=
>div&=3Bgt=3D3B&=3Blt=3D<br>>=3B >=3B=3D3Bbr&=3Bgt=3D3B&=3Bl=
>t=3D3B/div&=3Bgt=3D3B&=3Blt=3D3Bdiv&=3Bgt=3D3BThank you=3D3D2C&=
>=3Blt=3D3B/div&=3Bgt=3D3B&=3Blt=3D<br>>=3B >=3B=3D3Bdiv&=3Bgt=
>=3D3B&=3Bamp=3D3Bnbsp=3D3D3B-=3D3D<=3Bbr>=3B&=3Bgt=3D3B &=3Bgt=
>=3D3B&=3Bgt=3D3B Jay&=3Blt=3D3B/div&=3Bgt=3D3B=3D<br>>=3B >=3B=
>&=3Blt=3D3Bbr&=3Bgt=3D3B&=3Blt=3D3Bbr&=3Bgt=3D3B&=3Blt=3D3B/=
>div&=3Bgt=3D3B &=3Blt=3D3B/div&=3Bgt=3D3B&=3Blt=3D<b=
>r>>=3B >=3B=3D3B/body&=3Bgt=3D3B<=3Bbr>=3B&=3Bgt=3D3B &=3B=
>gt=3D3B&=3Bgt=3D3B&=3Blt=3D3B/html&=3Bgt=3D3B=3D3D<=3Bbr>=3B&a=
>mp=3Bgt=3D3B &=3Bgt=3D3B&=3B=3D<br>>=3B >=3Bgt=3D3B<=3Bbr>=3B=
>&=3Bgt=3D3B &=3Bgt=3D3B&=3Bgt=3D3B--_d2a02ece-d492-410e-88fb-fb537=
>37d7219_--<=3Bbr>=3B<=3B=3D<br>>=3B >=3B/div>=3B<=3B/div>=
>=3B <=3B/div>=3B<=3B/body>=3B<br>>=3B >=3B<=3B/htm=
>l>=3B=3D<br>>=3B >=3B<br>>=3B >=3B--_7877d7e8-cb4a-4989-bdcd-d406=
>e5b1f51f_--<br></div></div></div> </div></body>
></html>=
>
>--_13e6ee6a-034c-469d-aa83-18379d050866_--
More information about the M3devel
mailing list