Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 26 Feb 2013 05:30:50 -0600 Date: Tue, 26 Feb 2013 11:30:48 +0000 From: lipska the kat <"nospam at neversurrender dot co dot uk"> Organization: Trollbusters 3 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: BlueJ don't know what i did wrong References: <638ed624-9eba-44eb-bcbf-68466e5bb5f1@googlegroups.com> <42d76fca-d365-4030-ae8c-07a806eab87c@googlegroups.com> <1wtai7dd80h80$.6rbtwoyou3gh.dlg@40tude.net> <5q6dnc3pF_HJzLfMnZ2dnUVZ7s-dnZ2d@bt.com> <77afaabf-ec0f-46d6-b3ea-d8f186dbf7e4@googlegroups.com> <512c2745$0$289$14726298@news.sunsite.dk> <3a2dnXBuTbOY4rHMnZ2dnUVZ8iWdnZ2d@bt.com> <0I%Ws.96474$Ln.24770@newsfe22.iad> In-Reply-To: <0I%Ws.96474$Ln.24770@newsfe22.iad> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <672dncokKZ13AbHMnZ2dnUVZ8oadnZ2d@bt.com> Lines: 73 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-nNyBiaX9xSdNgj9larntDvfh6cB+1OsfZig2s7ml+25O1lqxoO852EG+r95ZHzMXYigxKCGwu8CQFKq!i8G///SOBuWvWuQqQBH1mn3HEp1fG8qsecdU4jnXuIpXp02iHPW8vxFlmkJBBcB7G/nOAIqreTk= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 4469 Xref: csiph.com comp.lang.java.programmer:22525 On 26/02/13 09:59, Arved Sandstrom wrote: > On 02/26/2013 05:23 AM, lipska the kat wrote: > [ SNIP ] > >> What's the contract of Deque ... a double ended queue? >> That in itself breaks the (humanly acceptable) contract of Queue. >> If a Queue is double ended it's not (conceptually) a Queue is it? >> >> Stack = LIFO >> Queue = FIFO >> >> Anything else isn't > [ SNIP ] > >> >> lipska >> > A deque (double ended queue) is a queue generalization. Despite the > name, a deque is not a queue, but a queue is a deque. You have this the wrong way round I'm afraid. A Deque 'is a' Queue because it extends Queue, you can call Queue methods on Deque but you cannot call Deque methods on Queue. A Queue is most definitely NOT a Deque. These are first year comp sci concepts really. A Queue is Fist In First Out, I can't see any reasonable description of Queue being anything else. We all know what Queue is, if you want to change the definition of Queue then you need to call it something else, for example a PriorityQueue has nodes that contain the queued item plus a priority, it's not a Queue is it? it's a PriorityQueue. Pedantic? well yes, aren't computers the ultimate pedants? A Deque is a what ... Anything in, anything out any time, and no, it doesn't have an index but it does have removeFirstOccurrence and removeLastOccurrence which are as close as you can get to random access as to make no odds. It's muddy, confused design > You made a point of using things appropriately by saying "If you use > Vector methods on a Stack then you are intentionally breaking the > contract of Stack". The same applies to stack or queue usages of Deque; But it isn't, can't you see, first order methods on Stack are Stack type methods, first order methods on Deque are ... what exactly, a whole bunch of duplicated methods of Stack and Queue and who knows what else > in the latter case since Deque implements Queue, Deque *extends* Queue, they are both interfaces (I'm reading the API docs here) > you work through the > lens of Queue. If wanting stack behaviour, you use the Deque methods > that are intended for stack behaviour. Exactly what you were advising. Yea, well we are coming up against the Law of Diminishing returns here I think. The contract of an interface is the collection of methods it publishes. [where interface = Interface or Class or Enum etc] lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun