[M3devel] STL algorithms? sort/unique?
mika at async.caltech.edu
mika at async.caltech.edu
Sat Sep 29 20:29:48 CEST 2012
Well that depends on how you maintain the vector, no?
SortedTable uses "treaps" which are supposed to be good data structures.
Too new to have made it into Knuth, last I checked. The amortized cost
of your operations shouldn't be much worse than with your method, with
the additional benefit that the sorted order is maintained dynamically.
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,
say...)
The Modula-3 approach is that you figure out what you want to do, pick
the ADT you want that provides the minimal set of operations, import
that interface, 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, actually.
I suspect there are many things you can do with them that no one has
tried.)
Mika
Jay K writes:
>--_7877d7e8-cb4a-4989-bdcd-d406e5b1f51f_
>Content-Type: text/plain; charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
>The following is very efficient:
>
>run through a bunch of records=2C picking out one number from some of thema=
>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=
>erator
>
>STL has this wonderful separation of algorithms from containers=2C via iter=
>ators.I suspect very few other libraries do.And it could be that most langu=
>ages don't support it.It doesn't appear I can easily sort a sequence=2C unl=
>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=
> it to work. It turns out I can reasonably well bound the size of the data=
>=2C so I'm using an open array...and I have to keep track of my position in=
>stead of using addhi/push_back.Not happy.At some point I might give up and =
>write the backend in C++..at which point I might as well write a C++ fronte=
>nd anywa.
>
>
>I absolutely do not want a sorted table and unique upon insert.That is much=
> less efficient.What I'm describing uses temporarily larger working set but=
> vastly less CPU.An array that gets sorted/uniqued occasionally=2C like jus=
>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=2C 28 Sep 2012 01:04:48 -0700
>> From: mika at async.caltech.edu
>>=20
>>=20
>> BTW I had the same experience when I first started using Modula-3.
>> It was painful to jump through all its hoops=2C coming from C=2C where yo=
>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.
>>=20
>> But after a while I really came to appreciate the value of things like th=
>e
>> language's telling me I'm using the wrong data structure instead of
>> just letting me use the same "nice=2C terse=2C efficient" syntax to write
>> a crappy program :-)
>>=20
>> mika writes:
>> >You're using the wrong (abstract) data structure if you want sort and un=
>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 increasing
>> >or decreasing order.
>> >
>> > Mika
>> >
>> >Jay K writes:
>> >>--_d2a02ece-d492-410e-88fb-fb53737d7219_
>> >>Content-Type: text/plain=3B charset=3D"iso-8859-1"
>> >>Content-Transfer-Encoding: quoted-printable
>> >>
>> >> I have an IntSeq.T with a bunch of integers. =3D20
>> >> What is a good terse efficient idiom for sort and unique? =3D20
>> >>
>> >> In C++ I would say: vector<int> a=3D3B a.push_back(..=
>.)=3D3B =3D
>> >> a.push_back(...)=3D3B std::sort(a.begin()=3D2C a.end())=
>=3D3B =3D
>> >> a.resize(std::unique(a.begin()=3D2C a.end()) - a.begin())=3D3B =
>for (aut=3D
>> >>o i =3D3D a.begin()=3D3B i !=3D3D a.end()=3D3B ++i) {
>> >> do stuff with *i }=3D20
>> >> Nice=3D2C terse=3D2C efficient. In Modula-3? =3D20
>> >>
>> >>I know that unique is one of the easiest algorithms to manually write i=
>nlin=3D
>> >>e=3D2Cbut I shouldn't have to.
>> >>
>> >>(I'm really trying to stay in Modula-3 here=3D2C but it is definitely a=
> strug=3D
>> >>gle. :( )
>> >>
>> >>Thank you=3D2C - Jay
>> >>
>> >> =3D
>> >>
>> >>--_d2a02ece-d492-410e-88fb-fb53737d7219_
>> >>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'> =3D3B  =3D3B&nb=
>sp=3D3BI have =3D
>> >>an IntSeq.T with a bunch of integers. =3D3B  =3D3B =3D3B<br=
>><div><spa=3D
>> >>n style=3D3D"font-size: 12pt=3D3B "> =3D3B  =3D3B</span><span s=
>tyle=3D3D"font=3D
>> >>-size: 12pt=3D3B "> =3D3B</span>What is a good terse efficient idio=
>m for so=3D
>> >>rt and unique?<span style=3D3D"font-size: 12pt=3D3B "> =3D3B  =
>=3D3B</span><=3D
>> >>span style=3D3D"font-size: 12pt=3D3B "> =3D3B</span></div><div><br>=
></div><div=3D
>> >>><br></div><div> =3D3B  =3D3B In C++ I would say:<span style=3D=
>3D"font-si=3D
>> >>ze: 12pt=3D3B "> =3D3B  =3D3B</span><span style=3D3D"font-size:=
> 12pt=3D3B ">&=3D
>> >>nbsp=3D3B</span></div><div><span style=3D3D"font-size: 12pt=3D3B ">&nbs=
>p=3D3B  =3D
>> >>=3D3B</span><span style=3D3D"font-size: 12pt=3D3B "> =3D3B</span>ve=
>ctor<=3D3Bin=3D
>> >>t>=3D3B a=3D3B<span style=3D3D"font-size: 12pt=3D3B "> =3D3B &nbs=
>p=3D3B</span><sp=3D
>> >>an style=3D3D"font-size: 12pt=3D3B "> =3D3B</span></div><div><span =
>style=3D3D"f=3D
>> >>ont-size: 12pt=3D3B "> =3D3B  =3D3B</span><span style=3D3D"font=
>-size: 12pt=3D
>> >>=3D3B "> =3D3B</span>a.push_back(...)=3D3B<span style=3D3D"font-siz=
>e: 12pt=3D3B "=3D
>> >>> =3D3B  =3D3B</span><span style=3D3D"font-size: 12pt=3D3B ">&n=
>bsp=3D3B</span=3D
>> >>></div><div><div><span style=3D3D"font-size: 12pt=3D3B "> =3D3B &nb=
>sp=3D3B</spa=3D
>> >>n><span style=3D3D"font-size: 12pt=3D3B "> =3D3B</span>a.push_back(=
>...)=3D3B<sp=3D
>> >>an style=3D3D"font-size: 12pt=3D3B "> =3D3B  =3D3B</span><span =
>style=3D3D"fon=3D
>> >>t-size: 12pt=3D3B "> =3D3B</span></div><div><span style=3D3D"font-s=
>ize: 12pt=3D
>> >>=3D3B "> =3D3B  =3D3B</span><span style=3D3D"font-size: 12pt=3D=
>3B "> =3D3B<=3D
>> >>/span>std::sort(a.begin()=3D2C a.end())=3D3B<span style=3D3D"font-size:=
> 12pt=3D3B "=3D
>> >>> =3D3B  =3D3B</span><span style=3D3D"font-size: 12pt=3D3B ">&n=
>bsp=3D3B</span=3D
>> >>></div><div><span style=3D3D"font-size: 12pt=3D3B "> =3D3B  =3D=
>3B</span><sp=3D
>> >>an style=3D3D"font-size: 12pt=3D3B "> =3D3B</span>a.resize(std::uni=
>que(a.begi=3D
>> >>n()=3D2C a.end()) - a.begin())=3D3B<span style=3D3D"font-size: 12pt=3D3=
>B "> =3D3B=3D
>> >>  =3D3B</span><span style=3D3D"font-size: 12pt=3D3B "> =3D3B</s=
>pan></div><d=3D
>> >>iv><span style=3D3D"font-size: 12pt=3D3B "> =3D3B  =3D3B for (a=
>uto i =3D3D a.=3D
>> >>begin()=3D3B i !=3D3D a.end()=3D3B ++i)</span></div><div><span style=3D=
>3D"font-size=3D
>> >>: 12pt=3D3B "> =3D3B  =3D3B {<br> =3D3B  =3D3B  =3D=
>3B do stuff with=3D
>> >> *i</span></div><div><span style=3D3D"font-size: 12pt=3D3B "> =3D3B=
>  =3D3B =3D
>> >>}</span></div><div> =3D3B</div><div><br></div><div><span style=3D3D=
>"font-si=3D
>> >>ze: 12pt=3D3B "> =3D3B  =3D3B</span><span style=3D3D"font-size:=
> 12pt=3D3B ">&=3D
>> >>nbsp=3D3B</span>Nice=3D2C terse=3D2C efficient.<span style=3D3D"font-si=
>ze: 12pt=3D3B =3D
>> >>"> =3D3B  =3D3B</span><span style=3D3D"font-size: 12pt=3D3B ">&=
>nbsp=3D3B</spa=3D
>> >>n></div><div><span style=3D3D"font-size: 12pt=3D3B "> =3D3B  =
>=3D3B</span><s=3D
>> >>pan style=3D3D"font-size: 12pt=3D3B "> =3D3B</span>In Modula-3?<spa=
>n style=3D3D=3D
>> >>"font-size: 12pt=3D3B "> =3D3B  =3D3B</span><span style=3D3D"fo=
>nt-size: 12p=3D
>> >>t=3D3B "> =3D3B</span></div><div><br></div><div><br></div><div>I kn=
>ow that =3D
>> >>unique is one of the easiest algorithms to manually write inline=3D2C</=
>div><d=3D
>> >>iv>but I shouldn't have to.</div><div><br></div><div><br></div><div>(I'=
>m re=3D
>> >>ally trying to stay in Modula-3 here=3D2C but it is definitely a strugg=
>le. :(=3D
>> >> )</div><div><br></div><div><br></div><div>Thank you=3D2C</div><div>&nb=
>sp=3D3B-=3D
>> >> Jay</div><br><br></div> </div></body>
>> >></html>=3D
>> >>
>> >>--_d2a02ece-d492-410e-88fb-fb53737d7219_--
> =
>
>--_7877d7e8-cb4a-4989-bdcd-d406e5b1f51f_
>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'><div><span style=3D"font-size: 1=
>2pt=3B ">The following is very efficient:</span></div><div><br></div><div><=
>br></div><div>run through a bunch of records=2C picking out one number from=
> some of them</div><div>append those numbers to a growing vector</div><div>=
>sort the vector</div><div>unique the vector</div><div><br></div><div><br></=
>div><div>sequence allows for random access..but only via a function...</div=
>><div>or maybe an iterator</div><div><br></div><div><br></div><div>STL has =
>this wonderful separation of algorithms from containers=2C via iterators.</=
>div><div>I suspect very few other libraries do.</div><div>And it could be t=
>hat most languages don't support it.</div><div>It doesn't appear I can easi=
>ly sort a sequence=2C unless I copy the data out into an array -- gross ine=
>fficiency.</div><div><br></div><div><br></div><div>I've hacked something ve=
>ry manual together..and it is taking forever to get it to work.</div><div>&=
>nbsp=3B It turns out I can reasonably well bound the size of the data=2C so=
> I'm using an open array...and I have to keep track of my position instead =
>of using addhi/push_back.</div><div>Not happy.</div><div>At some point I mi=
>ght give up and write the backend in C++..at which point I might as well wr=
>ite a C++ frontend anywa.</div><div><br></div><div><br></div><div><br></div=
>><div>I absolutely do not want a sorted table and unique upon insert.</div>=
><div>That is much less efficient.</div><div>What I'm describing uses tempor=
>arily larger working set but vastly less CPU.</div><div>An array that gets =
>sorted/uniqued occasionally=2C like just once.</div><div>And not ongoing ma=
>intainence for every single add.</div><div><br></div><div><br></div><div><b=
>r></div><div> =3B- Jay</div><div><br><br><br><div><div id=3D"SkyDrivePl=
>aceholder"></div>>=3B To: jay.krell at cornell.edu<br>>=3B CC: m3devel at ele=
>gosoft.com<br>>=3B Subject: Re: [M3devel] STL algorithms? sort/unique?<br=
>>>=3B Date: Fri=2C 28 Sep 2012 01:04:48 -0700<br>>=3B From: mika at async.=
>caltech.edu<br>>=3B <br>>=3B <br>>=3B BTW I had the same experience w=
>hen I first started using Modula-3.<br>>=3B It was painful to jump throug=
>h all its hoops=2C coming from C=2C where you<br>>=3B can do whatever you=
> want to whatever bits happen to be sloshing around<br>>=3B your machine.=
> C++ from what I have seen mainly lets you do that to<br>>=3B more bits =
>in fewer lines of code.<br>>=3B <br>>=3B But after a while I really cam=
>e to appreciate the value of things like the<br>>=3B language's telling m=
>e I'm using the wrong data structure instead of<br>>=3B just letting me u=
>se the same "nice=2C terse=2C efficient" syntax to write<br>>=3B a crappy=
> program :-)<br>>=3B <br>>=3B mika writes:<br>>=3B >=3BYou're using=
> the wrong (abstract) data structure if you want sort and unique.<br>>=3B=
> >=3B<br>>=3B >=3BA "sequence" is meant to be accessed sequentially..=
>.<br>>=3B >=3B<br>>=3B >=3BNot knowing precisely what you're doing =
>it sounds like you might want a<br>>=3B >=3BSortedTable... you can get =
>unique on insert and access it in increasing<br>>=3B >=3Bor decreasing =
>order.<br>>=3B >=3B<br>>=3B >=3B Mika<br>>=3B >=3B<br>>=3B=
> >=3BJay K writes:<br>>=3B >=3B>=3B--_d2a02ece-d492-410e-88fb-fb537=
>37d7219_<br>>=3B >=3B>=3BContent-Type: text/plain=3B charset=3D"iso-8=
>859-1"<br>>=3B >=3B>=3BContent-Transfer-Encoding: quoted-printable<br=
>>>=3B >=3B>=3B<br>>=3B >=3B>=3B I have an IntSeq.T with a bu=
>nch of integers. =3D20<br>>=3B >=3B>=3B What is a good terse eff=
>icient idiom for sort and unique? =3D20<br>>=3B >=3B>=3B<br>>=3B =
>>=3B>=3B In C++ I would say: vector<=3Bint>=3B a=3D3B =
> a.push_back(...)=3D3B =3D<br>>=3B >=3B>=3B a.push_back(...)=
>=3D3B std::sort(a.begin()=3D2C a.end())=3D3B =3D<br>>=3B >=
>=3B>=3B a.resize(std::unique(a.begin()=3D2C a.end()) - a.begin())=3D3B =
> for (aut=3D<br>>=3B >=3B>=3Bo i =3D3D a.begin()=3D3B i !=3D3D a.=
>end()=3D3B ++i) {<br>>=3B >=3B>=3B do stuff with *i }=3D20=
><br>>=3B >=3B>=3B Nice=3D2C terse=3D2C efficient. In Modula=
>-3? =3D20<br>>=3B >=3B>=3B<br>>=3B >=3B>=3BI know that unique=
> is one of the easiest algorithms to manually write inlin=3D<br>>=3B >=
>=3B>=3Be=3D2Cbut I shouldn't have to.<br>>=3B >=3B>=3B<br>>=3B &g=
>t=3B>=3B(I'm really trying to stay in Modula-3 here=3D2C but it is defini=
>tely a strug=3D<br>>=3B >=3B>=3Bgle. :( )<br>>=3B >=3B>=3B<br>&=
>gt=3B >=3B>=3BThank you=3D2C - Jay<br>>=3B >=3B>=3B<br>>=3B >=
>=3B>=3B =3D<br>>=3B >=3B>=3B<br>>=3B >=3B>=3B--_d2=
>a02ece-d492-410e-88fb-fb53737d7219_<br>>=3B >=3B>=3BContent-Type: tex=
>t/html=3B charset=3D"iso-8859-1"<br>>=3B >=3B>=3BContent-Transfer-Enc=
>oding: quoted-printable<br>>=3B >=3B>=3B<br>>=3B >=3B>=3B<=3B=
>html>=3B<br>>=3B >=3B>=3B<=3Bhead>=3B<br>>=3B >=3B>=3B<=
>=3Bstyle>=3B<=3B!--<br>>=3B >=3B>=3B.hmmessage P<br>>=3B >=3B=
>>=3B{<br>>=3B >=3B>=3Bmargin:0px=3D3B<br>>=3B >=3B>=3Bpadding=
>:0px<br>>=3B >=3B>=3B}<br>>=3B >=3B>=3Bbody.hmmessage<br>>=3B=
> >=3B>=3B{<br>>=3B >=3B>=3Bfont-size: 12pt=3D3B<br>>=3B >=3B&=
>gt=3Bfont-family:Calibri<br>>=3B >=3B>=3B}<br>>=3B >=3B>=3B--&g=
>t=3B<=3B/style>=3B<=3B/head>=3B<br>>=3B >=3B>=3B<=3Bbody cl=
>ass=3D3D'hmmessage'>=3B<=3Bdiv dir=3D3D'ltr'>=3B&=3Bnbsp=3D3B &=
>=3Bnbsp=3D3B&=3Bnbsp=3D3BI have =3D<br>>=3B >=3B>=3Ban IntSeq.T wi=
>th a bunch of integers.&=3Bnbsp=3D3B &=3Bnbsp=3D3B&=3Bnbsp=3D3B<=
>=3Bbr>=3B<=3Bdiv>=3B<=3Bspa=3D<br>>=3B >=3B>=3Bn style=3D3D"f=
>ont-size: 12pt=3D3B ">=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B<=3B/span>=
>=3B<=3Bspan style=3D3D"font=3D<br>>=3B >=3B>=3B-size: 12pt=3D3B "&g=
>t=3B&=3Bnbsp=3D3B<=3B/span>=3BWhat is a good terse efficient idiom f=
>or so=3D<br>>=3B >=3B>=3Brt and unique?<=3Bspan style=3D3D"font-siz=
>e: 12pt=3D3B ">=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B<=3B/span>=3B<=
>=3B=3D<br>>=3B >=3B>=3Bspan style=3D3D"font-size: 12pt=3D3B ">=3B&a=
>mp=3Bnbsp=3D3B<=3B/span>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=
>=3B<=3B/div>=3B<=3Bdiv=3D<br>>=3B >=3B>=3B>=3B<=3Bbr>=3B&=
>lt=3B/div>=3B<=3Bdiv>=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B In C++ I wo=
>uld say:<=3Bspan style=3D3D"font-si=3D<br>>=3B >=3B>=3Bze: 12pt=3D3=
>B ">=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B<=3B/span>=3B<=3Bspan style=
>=3D3D"font-size: 12pt=3D3B ">=3B&=3B=3D<br>>=3B >=3B>=3Bnbsp=3D3=
>B<=3B/span>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bspan style=3D3D"font=
>-size: 12pt=3D3B ">=3B&=3Bnbsp=3D3B &=3Bnbsp=3D<br>>=3B >=3B>=
>=3B=3D3B<=3B/span>=3B<=3Bspan style=3D3D"font-size: 12pt=3D3B ">=3B=
>&=3Bnbsp=3D3B<=3B/span>=3Bvector&=3Blt=3D3Bin=3D<br>>=3B >=3B=
>>=3Bt&=3Bgt=3D3B a=3D3B<=3Bspan style=3D3D"font-size: 12pt=3D3B ">=
>=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B<=3B/span>=3B<=3Bsp=3D<br>>=3B =
>>=3B>=3Ban style=3D3D"font-size: 12pt=3D3B ">=3B&=3Bnbsp=3D3B<=
>=3B/span>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bspan style=3D3D"f=3D<br>=
>>=3B >=3B>=3Bont-size: 12pt=3D3B ">=3B&=3Bnbsp=3D3B &=3Bnbsp=
>=3D3B<=3B/span>=3B<=3Bspan style=3D3D"font-size: 12pt=3D<br>>=3B &g=
>t=3B>=3B=3D3B ">=3B&=3Bnbsp=3D3B<=3B/span>=3Ba.push_back(...)=3D=
>3B<=3Bspan style=3D3D"font-size: 12pt=3D3B "=3D<br>>=3B >=3B>=3B>=
>=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B<=3B/span>=3B<=3Bspan style=3D3D"=
>font-size: 12pt=3D3B ">=3B&=3Bnbsp=3D3B<=3B/span=3D<br>>=3B >=3B=
>>=3B>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bdiv>=3B<=3Bspan style=
>=3D3D"font-size: 12pt=3D3B ">=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B<=3B/s=
>pa=3D<br>>=3B >=3B>=3Bn>=3B<=3Bspan style=3D3D"font-size: 12pt=3D=
>3B ">=3B&=3Bnbsp=3D3B<=3B/span>=3Ba.push_back(...)=3D3B<=3Bsp=3D=
><br>>=3B >=3B>=3Ban style=3D3D"font-size: 12pt=3D3B ">=3B&=3Bnbs=
>p=3D3B &=3Bnbsp=3D3B<=3B/span>=3B<=3Bspan style=3D3D"fon=3D<br>>=
>=3B >=3B>=3Bt-size: 12pt=3D3B ">=3B&=3Bnbsp=3D3B<=3B/span>=3B&=
>lt=3B/div>=3B<=3Bdiv>=3B<=3Bspan style=3D3D"font-size: 12pt=3D<br>&=
>gt=3B >=3B>=3B=3D3B ">=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B<=3B/span=
>>=3B<=3Bspan style=3D3D"font-size: 12pt=3D3B ">=3B&=3Bnbsp=3D3B<=
>=3B=3D<br>>=3B >=3B>=3B/span>=3Bstd::sort(a.begin()=3D2C a.end())=
>=3D3B<=3Bspan style=3D3D"font-size: 12pt=3D3B "=3D<br>>=3B >=3B>=3B=
>>=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B<=3B/span>=3B<=3Bspan style=3D=
>3D"font-size: 12pt=3D3B ">=3B&=3Bnbsp=3D3B<=3B/span=3D<br>>=3B >=
>=3B>=3B>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bspan style=3D3D"font-si=
>ze: 12pt=3D3B ">=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B<=3B/span>=3B<=
>=3Bsp=3D<br>>=3B >=3B>=3Ban style=3D3D"font-size: 12pt=3D3B ">=3B&a=
>mp=3Bnbsp=3D3B<=3B/span>=3Ba.resize(std::unique(a.begi=3D<br>>=3B >=
>=3B>=3Bn()=3D2C a.end()) - a.begin())=3D3B<=3Bspan style=3D3D"font-size=
>: 12pt=3D3B ">=3B&=3Bnbsp=3D3B=3D<br>>=3B >=3B>=3B &=3Bnbsp=
>=3D3B<=3B/span>=3B<=3Bspan style=3D3D"font-size: 12pt=3D3B ">=3B&am=
>p=3Bnbsp=3D3B<=3B/span>=3B<=3B/div>=3B<=3Bd=3D<br>>=3B >=3B&g=
>t=3Biv>=3B<=3Bspan style=3D3D"font-size: 12pt=3D3B ">=3B&=3Bnbsp=
>=3D3B &=3Bnbsp=3D3B for (auto i =3D3D a.=3D<br>>=3B >=3B>=3Bbegin(=
>)=3D3B i !=3D3D a.end()=3D3B ++i)<=3B/span>=3B<=3B/div>=3B<=3Bdiv=
>>=3B<=3Bspan style=3D3D"font-size=3D<br>>=3B >=3B>=3B: 12pt=3D3B =
>">=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B {<=3Bbr>=3B&=3Bnbsp=3D3B &a=
>mp=3Bnbsp=3D3B &=3Bnbsp=3D3B do stuff with=3D<br>>=3B >=3B>=3B *i&=
>lt=3B/span>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bspan style=3D3D"font-s=
>ize: 12pt=3D3B ">=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B =3D<br>>=3B >=
>=3B>=3B}<=3B/span>=3B<=3B/div>=3B<=3Bdiv>=3B&=3Bnbsp=3D3B&=
>lt=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3B=
><=3Bspan style=3D3D"font-si=3D<br>>=3B >=3B>=3Bze: 12pt=3D3B ">=
>=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B<=3B/span>=3B<=3Bspan style=3D3D"=
>font-size: 12pt=3D3B ">=3B&=3B=3D<br>>=3B >=3B>=3Bnbsp=3D3B<=
>=3B/span>=3BNice=3D2C terse=3D2C efficient.<=3Bspan style=3D3D"font-siz=
>e: 12pt=3D3B =3D<br>>=3B >=3B>=3B">=3B&=3Bnbsp=3D3B &=3Bnbsp=
>=3D3B<=3B/span>=3B<=3Bspan style=3D3D"font-size: 12pt=3D3B ">=3B&am=
>p=3Bnbsp=3D3B<=3B/spa=3D<br>>=3B >=3B>=3Bn>=3B<=3B/div>=3B<=
>=3Bdiv>=3B<=3Bspan style=3D3D"font-size: 12pt=3D3B ">=3B&=3Bnbsp=
>=3D3B &=3Bnbsp=3D3B<=3B/span>=3B<=3Bs=3D<br>>=3B >=3B>=3Bpan=
> style=3D3D"font-size: 12pt=3D3B ">=3B&=3Bnbsp=3D3B<=3B/span>=3BIn=
> Modula-3?<=3Bspan style=3D3D=3D<br>>=3B >=3B>=3B"font-size: 12pt=
>=3D3B ">=3B&=3Bnbsp=3D3B &=3Bnbsp=3D3B<=3B/span>=3B<=3Bspan s=
>tyle=3D3D"font-size: 12p=3D<br>>=3B >=3B>=3Bt=3D3B ">=3B&=3Bnbsp=
>=3D3B<=3B/span>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/d=
>iv>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3BI know =
>that =3D<br>>=3B >=3B>=3Bunique is one of the easiest algorithms to m=
>anually write inline=3D2C<=3B/div>=3B<=3Bd=3D<br>>=3B >=3B>=3Bi=
>v>=3Bbut I shouldn't have to.<=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=
>=3B<=3B/div>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/div>=3B<=3Bdiv&g=
>t=3B(I'm re=3D<br>>=3B >=3B>=3Bally trying to stay in Modula-3 here=
>=3D2C but it is definitely a struggle. :(=3D<br>>=3B >=3B>=3B )<=3B=
>/div>=3B<=3Bdiv>=3B<=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3B<=
>=3Bbr>=3B<=3B/div>=3B<=3Bdiv>=3BThank you=3D2C<=3B/div>=3B<=
>=3Bdiv>=3B&=3Bnbsp=3D3B-=3D<br>>=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/html>=3B=3D<br>>=3B >=3B&=
>gt=3B<br>>=3B >=3B>=3B--_d2a02ece-d492-410e-88fb-fb53737d7219_--<br><=
>/div></div> </div></body>
></html>=
>
>--_7877d7e8-cb4a-4989-bdcd-d406e5b1f51f_--
More information about the M3devel
mailing list