Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 83903 invoked from network); 9 Aug 2010 00:55:02 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Aug 2010 00:55:02 -0000 Received: (qmail 17773 invoked by uid 500); 9 Aug 2010 00:55:02 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 17704 invoked by uid 500); 9 Aug 2010 00:55:01 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 17695 invoked by uid 99); 9 Aug 2010 00:55:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Aug 2010 00:55:01 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of yanglang@gmail.com designates 74.125.82.43 as permitted sender) Received: from [74.125.82.43] (HELO mail-ww0-f43.google.com) (74.125.82.43) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Aug 2010 00:54:55 +0000 Received: by wwb18 with SMTP id 18so555500wwb.0 for ; Sun, 08 Aug 2010 17:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=+L9sE82KQjy+8ed0/8XvklORyoZseYFWivfqdG9zXPM=; b=tURcAlfP6oxuHNulhBrtuc4J+pk9BsdMeMafkA3IyLZcopOxmvBuOtTIZzpmE8KskO 8ceT87KI8HwMyibn+hwuWs8IQlI7StsHsThh7ArpfgCwQLqwI/KWeOc8FsapI9oA7Sli gB2MS1fR+LhC2VGZuVHvoMx+GrAdcuIl1hWW0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=PuN42ZHb7qGVHxdbaxGrQGkqORVSLmG/ACkpv2ZJBKsKXCpjkS5egYnsoNdk4sycqw PeF5aoM3+ooWil21QFKU2f+D19agUQg8DaZPT7UrxTLKObIfK747sNLrg9t/fuXKqGqE d+LV6qkK+XLuI2gOsCtWN5vlgg5oExYWrAztA= MIME-Version: 1.0 Received: by 10.216.5.79 with SMTP id 57mr1992347wek.93.1281315273765; Sun, 08 Aug 2010 17:54:33 -0700 (PDT) Received: by 10.216.23.203 with HTTP; Sun, 8 Aug 2010 17:54:33 -0700 (PDT) In-Reply-To: References: Date: Sun, 8 Aug 2010 20:54:33 -0400 Message-ID: Subject: Re: [classlib][imageio]PositionStack From: Lang Yang To: dev@harmony.apache.org Content-Type: multipart/alternative; boundary=0016364c7ca7bcf3a4048d59756a --0016364c7ca7bcf3a4048d59756a Content-Type: text/plain; charset=UTF-8 Never mind, I think I can just cast int to long, instead of creating a new int stack. On Sun, Aug 8, 2010 at 8:46 PM, Lang Yang wrote: > Hello Alexey, > > Thanks for the explanation. It happens that an int stack is also needed. It > just looks a little bit redundant to have two almost the same classes at > here though, the only difference is the datetype, one is long, the other one > is int ;) > > Regards, > > Lang > > On Fri, Aug 6, 2010 at 4:38 AM, Alexey Petrenko < > alexey.a.petrenko@gmail.com> wrote: > >> I see at least two reasons: this class is not synchronized and it >> works with primitive types instead of objects. >> So it can be a bit faster on certain circumstances... >> >> Thanks. >> >> Alexey >> >> 2010/8/6 Lang Yang : >> > Hello guys, >> > >> > I was reviewing ImageIO, and found this class: >> > >> > javax.imageio.stream.ImageInputStreamImpl: >> > >> > private static class PositionStack { >> > private static final int SIZE = 10; >> > >> > private long[] values = new long[SIZE]; >> > private int pos = 0; >> > >> > void push(long v) { >> > if (pos >= values.length) { >> > ensure(pos + 1); >> > } >> > values[pos++] = v; >> > } >> > >> > long pop() { >> > return values[--pos]; >> > } >> > >> > boolean isEmpty() { >> > return pos == 0; >> > } >> > >> > private void ensure(int size) { >> > long[] arr = new long[Math.max(2 * values.length, size)]; >> > System.arraycopy(values, 0, arr, 0, values.length); >> > values = arr; >> > } >> > } >> > >> > Essentially, it's just a stack, but why do we create this class rather >> than >> > just use the standard Stack class? >> > >> > Regards, >> > >> > Lang >> > >> > > --0016364c7ca7bcf3a4048d59756a--