Re: Double linked list with one pointer

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Double linked list with one pointer
Date: 2003-12-07 05:21:12
Message-ID: 200312070521.hB75LCi03231@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Dunstan wrote:
>
>
> Bruce Momjian wrote:
>
> >Gaetano Mendola wrote:
> >
> >
> >>I don't think the article is available online, alas, but you can find some
> >>related source code demonstrating the technique at:
> >>
> >> http://www.semantics.org/tyr/tyr0_5/list.h
> >>
> >>
> >
> >That certainly is an amazing idea. You know the pointer you are coming
> >from so you can XOR to find the next pointer.
> >
> >I agree with a Tom that we don't have much use for double-link lists,
> >but is a nice idea.
> >
> >
>
>
> I must confess that it strikes me as a really really horrid and ugly
> hack - very likely to be error-prone and non-portable and undebuggable,
> and for almost no saving worth having. But maybe that's just me.
>
> In general I've been impressed with the quality of Pg code over the last
> 6 months or so - I'd hate to see it polluted by something like this.

Agreed, I just thought it was neat and I hadn't realized it was
possible.

Also, I don't think the problems for doing this for swaping values
without a temp table is relevant. In those cases, you are doing the
swap without a temp variable, and this is the problem, more than the XOR
itself, which is what we would use and use real temp table.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-12-07 05:50:26 Re: Double linked list with one pointer
Previous Message Joe Conway 2003-12-07 04:15:25 Re: [HACKERS] bytea, index and like operator again and