Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Jan Burse Newsgroups: comp.lang.java.programmer Subject: Re: Immutable Datastructures with good Sharing Date: Sun, 06 Nov 2011 16:08:55 +0100 Organization: albasani.net Lines: 23 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net 0gh8ValvcoOQDnlk5kru82EVL+KOf1wTyQor9/gBHzKuNrvbRMyWM6JMwuSoyld/rqf+71exkrA6HgsKKThCiQ== NNTP-Posting-Date: Sun, 6 Nov 2011 15:08:55 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="GNv1EOBZPq3qA/PLXJNBab+hJoPZKsAd0Zu/i+n3ORFPEg5qZ1ZjVX6T9o9eLJ0d8mqce50akzxbGDO2HvjQA6Adlkh/bQJON591MQ6txNzv38aXqABmAo50uSQ4n5l3"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20110928 Firefox/7.0.1 SeaMonkey/2.4.1 In-Reply-To: Cancel-Lock: sha1:MCpWkxM1I0yqmMoTenxW8W7N4GI= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9656 Andreas Leitgeb schrieb: > But then again, the queue(s) before and after re-arranging the > stacks do not share much data... Thats why I don't particularly like this solutions, and hope that there will come up some other suggestions... There is only a sharing between subsequent enQueue(), and also between subsequent deQueue(). But as soon as a deQueue() its the empty stack the other stack is reversed. Well that is not bad, but a little bit arbitrary. Maybe there are datastructures where something happens based on some bound, similarly like the elements allocated ahead in an ArrayList. When you create an ArrayList it will have a default allocation of 10 elements (implementation dependent) for use, and it then grows by 150% (implementation dependent) when additional elements are needed. But an ArrayList is not immutable. You cannot keep a pointer on it, it will get modified by subsequent operations... Bye