Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62681 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19586 invoked from network); 2 Sep 2012 19:45:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 19:45:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=theanomaly.is@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=theanomaly.is@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: theanomaly.is@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:37353] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/B4-17065-C47B3405 for ; Sun, 02 Sep 2012 15:45:16 -0400 Received: by lahl5 with SMTP id l5so3246615lah.29 for ; Sun, 02 Sep 2012 12:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=WXkXOR34kSkZRO9Ax1qlV/QB/ypHcNQrzdx0519g/vc=; b=DJT9aWj+VeqQqcwRWA9zARCqUBxVyJ7KPsXcrm/khXNBD0RU8FG0h3yS76iGwRDDR3 ofHVYxDcVjG8lC96WYdJ3Lby8FFe5vNfjeyP/xLRNN9Cg3baKFKSioSBS+YNbWztkLId KnaQ7cJU6/iQ1XywxWRdveWrQZRO9kllvyUzVSwLzP6/VOJM+V7CXa/mZhBoR//zz+EK 2fqp+Qk0KwSdP947Q/z8TrhcySxKgt6VkWSaNaqvQrJy/GdVqJW2rGmhCT0i+r0LLAC0 4iEH/KeQegefcE50vpwffy92KSuHuA6W7C83a8PSniDwxQ9btr1r7oru6ieVaOi1TYIz ijMg== MIME-Version: 1.0 Received: by 10.112.10.170 with SMTP id j10mr4772402lbb.39.1346615113376; Sun, 02 Sep 2012 12:45:13 -0700 (PDT) Received: by 10.112.12.178 with HTTP; Sun, 2 Sep 2012 12:45:13 -0700 (PDT) In-Reply-To: References: Date: Sun, 2 Sep 2012 15:45:13 -0400 Message-ID: To: Amaury Bouchard Cc: PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Question about hashtables implementation From: theanomaly.is@gmail.com (Sherif Ramadan) > > OK, thanks for the information. It explains why I didn't find anything in > the HashTable structure (unlike iterator pointer or the next free key). > Yes, because the hashtable is an ordered map. The only way to logically prepend to it is to rework the whole thing. That's generally how you prepend to a stack as well. You'll probably find that in most C implementations of a stack or a linked list the only way to prepend is to rebuild the entire stack or list. That's why the existing implementation is just doing the equivalent of what I demonstrated in PHP code (it creates a new hashtable). Line 2053 of ext/standard/array.c HashTable *new_hash; /* New hashtable for the stack */ > > You're right; I hadn't noticed that. > Side effect: add values at the beginning of an array could be very > time-consuming, according to its size. > It's generally more costly to do so, yes. > > > Thanks again for this link. I have the book of Sara (huge piece of work, > btw), and I found some good documentation. But more information wouldn't > hurt! :-) > Cheers :)