From owner-freebsd-hackers@FreeBSD.ORG Fri Apr 9 17:41:36 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD9D01065672 for ; Fri, 9 Apr 2010 17:41:36 +0000 (UTC) (envelope-from salfrancl.listas@gmail.com) Received: from mail-bw0-f216.google.com (mail-bw0-f216.google.com [209.85.218.216]) by mx1.freebsd.org (Postfix) with ESMTP id 49B3D8FC1E for ; Fri, 9 Apr 2010 17:41:35 +0000 (UTC) Received: by bwz8 with SMTP id 8so1243630bwz.3 for ; Fri, 09 Apr 2010 10:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=VWCn/25PVzV29j00ucL3uxd2mXYJFSnLYorirncimZc=; b=v2ua5BhgnkZd7MAoBTmETi0FWAU/xEdCPQTXthgrxOPx7svggcuOntjVouN2h1G3Tv ot8n50Mo/7UD2yrGXLv+i8136hcLaNZ/Qj3QFcBgiDThIphI125gIlxHi8kC2/umnkIe 8YHktWataBTYbRlVxkgY4750zxYvuEtr3UfAE= 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 :cc:content-type:content-transfer-encoding; b=rbpWaqtXIBX5BUVB36iDYK5xTS5QV5/8TDkG1YQ++Ve0wpIIgLFHIc7eHDGBrbQdBZ mKlPgexJ49uYkZz5wzvhhzItu8nWlQiNICJNDkg4o46ip4xx4lMOCj/R0uALrsolgrpF UkdY0f+VamU+fouJuHZ9xcRcxmrVZXrDyNrC0= MIME-Version: 1.0 Received: by 10.204.102.211 with HTTP; Fri, 9 Apr 2010 10:41:34 -0700 (PDT) In-Reply-To: References: Date: Fri, 9 Apr 2010 13:41:34 -0400 Received: by 10.204.73.165 with SMTP id q37mr417032bkj.100.1270834894743; Fri, 09 Apr 2010 10:41:34 -0700 (PDT) Message-ID: From: Leinier Cruz Salfran To: Alexander Churanov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers Subject: Re: c question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2010 17:41:36 -0000 On Fri, Apr 9, 2010 at 10:52 AM, Alexander Churanov wrote: > 2010/4/9 Leinier Cruz Salfran >> >> - use a matrix is faster than use a linked list? >> >> example: >> >> char *szColumnName[10]; >> unsigned short iColumnAge[10]; >> >> >> struct _llList { >> =A0struct _llList *prev, *next; >> =A0char szName[64]; >> =A0unsigned short iAge; >> =A0}; > > > Leinier , > This depends on what kind of operations are performed. For sequential > traversing, both are very appropriate. However, you can not perform a bin= ary > search on a list. You also can not combine two arrays into a single one w= ith > constant complexity. > Lists also have greater memory overhead for small structures. > My advice: always use arrays. > Use lists if: > 1) Copying items when the dynamic arrays grows is inappropriate. > 2) List-specific operations like O(1) splicing or O(1) insertions and > deletions are required. > Alexander Churanov > hello alexander i supposed that a matrix is much faster .. i coded my program to use matrix in that portion but i sent the question to see what others think about this thanks