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