From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Array or Vector? Date: Wed, 10 Sep 2008 08:57:31 -0700 Message-ID: <001c01c9135d$ef331b40$c2b22382@us.oracle.com> References: <2e338035-f71c-449a-bf25-9614e77d76ce@y21g2000hsf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1221062884 15313 80.91.229.12 (10 Sep 2008 16:08:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Sep 2008 16:08:04 +0000 (UTC) To: "=?iso-8859-1?Q?'Nordl=F6w'?=" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Sep 10 18:08:58 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KdSFQ-0004kQ-PK for geh-help-gnu-emacs@m.gmane.org; Wed, 10 Sep 2008 18:08:53 +0200 Original-Received: from localhost ([127.0.0.1]:51969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KdSEQ-0007PS-Kn for geh-help-gnu-emacs@m.gmane.org; Wed, 10 Sep 2008 12:07:50 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KdS4h-0003Lr-1F for help-gnu-emacs@gnu.org; Wed, 10 Sep 2008 11:57:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KdS4e-0003H4-8K for help-gnu-emacs@gnu.org; Wed, 10 Sep 2008 11:57:46 -0400 Original-Received: from [199.232.76.173] (port=46926 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KdS4e-0003Gl-3s for help-gnu-emacs@gnu.org; Wed, 10 Sep 2008 11:57:44 -0400 Original-Received: from agminet01.oracle.com ([141.146.126.228]:23399) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KdS4c-0000xX-CL for help-gnu-emacs@gnu.org; Wed, 10 Sep 2008 11:57:43 -0400 Original-Received: from rgmgw2.us.oracle.com (rgmgw2.us.oracle.com [138.1.186.111]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id m8AFvcR0005549; Wed, 10 Sep 2008 10:57:38 -0500 Original-Received: from acsmt700.oracle.com (acsmt700.oracle.com [141.146.40.70]) by rgmgw2.us.oracle.com (Switch-3.2.4/Switch-3.2.4) with ESMTP id m8AFvXAU023209; Wed, 10 Sep 2008 09:57:33 -0600 Original-Received: from dradamslap1 (/130.35.178.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Sep 2008 08:57:31 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <2e338035-f71c-449a-bf25-9614e77d76ce@y21g2000hsf.googlegroups.com> Thread-Index: AckTXVQQeAXPGJNnTO2ecByA8WnkpAAACjRQ X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:57394 Archived-At: > When, in Emacs Lisp, is it preferrable to use a list over a vector and > vice versa? > > My guess is > - vector: for fast static sequences > - list: for dynamically growing sequences Yes (growing, shrinking, ...). And array, not necessarily vector. See Elisp manual, node Sequences Arrays Vectors: An "array" is a single primitive object that has a slot for each of its elements. All the elements are accessible in constant time, but the length of an existing array cannot be changed. Strings, vectors, char-tables and bool-vectors are the four types of arrays. A list is a sequence of elements, but it is not a single primitive object; it is made of cons cells, one cell per element. Finding the Nth element requires looking through N cons cells, so elements farther from the beginning of the list take longer to access. But it is possible to add elements to the list, or remove elements. The Elisp manual is your friend.