Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #3050

Re: data structure that preserving insertion order

From "Scott Fluhrer" <sfluhrer@ix.netcom.com>
Newsgroups comp.lang.c
References <pan.2011.04.29.02.10.31.192000@Owner-PC.com> <c6a02a1d-fe65-4fe7-bc19-99bd026aeacd@j26g2000yqa.googlegroups.com> <pan.2011.04.29.12.42.37.649000@Owner-PC.com> <0.be0c9ded1648c0c8479c.20110429162315BST.87zkn984kc.fsf@bsb.me.uk> <pan.2011.04.29.16.16.12.154000@Owner-PC.com>
Subject Re: data structure that preserving insertion order
Message-ID <1304096983.846797@sj-nntpcache-2.cisco.com> (permalink)
Organization cisco.com
Date 2011-04-29 13:08 -0400

Show all headers | View raw


"Owner" <Owner@Owner-PC.com> wrote in message 
news:pan.2011.04.29.16.16.12.154000@Owner-PC.com...
> On Fri, 29 Apr 2011 16:23:15 +0100, Ben Bacarisse wrote:
>
>> Owner <Owner@Owner-PC.com> writes:
>> <snip>
>>> Yes exactly, preserving order like that but with large data
>>> like unicode mapping.  data structure preserving the inorder
>>> of character( character has its own value according
>>> character set but when inserted the character in some
>>> sort of data structure, it preserves inorder ) with able
>>> to search the character efficiently.
>>
>> I'm still not sure what you want.  In particular what is "Unicode
>> mapping"?  Presumably it maps Unicode code points to ... what?
>>
>> Anyway, any data structure that supports the mapping you want can be
>> made to record the insertion order, simply by maintaining a list at the
>> same time.  This so simple that I image it is not what you want but I
>> can't tell.  Why not say what the actual problem is that needs to be
>> solved?
>
> Trying to build tr unix tool that supports unicode.
>
> ascii is 128 characters so a array can hold characters.
>
> unicode is a little over 10,000 characters.

Unless you are on a strictly constrained environment, there is no problem 
having an array with 65,536 elements.  I wouldn't even bother trying to 
limit it to 10,000; memory is cheap enough that it doesn't warrent your time 
to reduce the size of the array to the unicode characters you'll actually 
see.

>
> thought a binary tree could be right structure.  but then
>
> I need preserve order which character goes in first.

Why does 'tr' need to remember the order that the characters were specified? 
Or, is it possible that a single unicode character might be converted into 
multiple (in which case you'll need to remember the order of the replacement 
characters)?  If the latter, that's easy enough; each array element might 
point to a string of unicode characters.

Remember, on today's processors, memory is cheap (unless, again, you're in a 
constained environment).  If throwing a few megabytes at the problem saves 
you time (designing, programming, debugging), it's a good tradeoff.

>
> Thank you for replies by the way.
> 

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

data structure that preserving insertion order Owner <Owner@Owner-PC.com> - 2011-04-28 22:10 -0400
  Re: data structure that preserving insertion order Peter Nilsson <airia@acay.com.au> - 2011-04-28 23:02 -0700
    Re: data structure that preserving insertion order Owner <Owner@Owner-PC.com> - 2011-04-29 08:06 -0400
  Re: data structure that preserving insertion order Paul N <gw7rib@aol.com> - 2011-04-29 05:18 -0700
    Re: data structure that preserving insertion order Owner <Owner@Owner-PC.com> - 2011-04-29 08:42 -0400
      Re: data structure that preserving insertion order Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-29 16:23 +0100
        Re: data structure that preserving insertion order Owner <Owner@Owner-PC.com> - 2011-04-29 12:16 -0400
          Re: data structure that preserving insertion order Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-29 18:15 +0100
            Re: data structure that preserving insertion order Owner <Owner@Owner-PC.com> - 2011-04-29 13:35 -0400
              Re: data structure that preserving insertion order Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-04-29 20:00 +0200
                Re: data structure that preserving insertion order Owner <Owner@Owner-PC.com> - 2011-04-29 14:15 -0400
              Re: data structure that preserving insertion order James Kuyper <jameskuyper@verizon.net> - 2011-04-29 19:17 -0400
          Re: data structure that preserving insertion order "Scott Fluhrer" <sfluhrer@ix.netcom.com> - 2011-04-29 13:08 -0400
          Re: data structure that preserving insertion order William Ahern <william@wilbur.25thandClement.com> - 2011-04-29 10:53 -0700
            Re: data structure that preserving insertion order Owner <Owner@Owner-PC.com> - 2011-04-29 14:17 -0400
              Re: data structure that preserving insertion order James Kuyper <jameskuyper@verizon.net> - 2011-04-29 19:24 -0400
              Re: data structure that preserving insertion order Gene <gene.ressler@gmail.com> - 2011-04-29 16:25 -0700

csiph-web