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


Groups > comp.lang.javascript > #23808

Re: Boolean spacerequirment in javascript

Newsgroups comp.lang.javascript
Date 2014-04-07 01:23 -0700
References <3f966da1-6f24-44bb-8f1e-ef833896693c@googlegroups.com> <1d16e75b-1801-4de7-a123-6b4d0528a36b@googlegroups.com>
Message-ID <37549a11-46c2-49fd-abcd-e94bc6a18429@googlegroups.com> (permalink)
Subject Re: Boolean spacerequirment in javascript
From jonas.thornvall@gmail.com

Show all headers | View raw


Den måndagen den 7:e april 2014 kl. 09:42:19 UTC+2 skrev Michael Haufe (TNO):
> On Sunday, April 6, 2014 11:58:28 PM UTC-5, jonas.t...@gmail.com wrote:
> 
> > I have a datastructure "array" over a user defined range, where i store information about natural numbers.
> 
> > 
> 
> > Right now i basicly store the actual number, and if it is a prime and how it will be presented.
> 
> > 
> 
> > Other properties like if the  number is square, cubic in fibonaci i generate on the fly since it is not as heavy as calculate the primes.
> 
> > 
> 
> > However i am thinking about moving these into the datastructure, but since the script can generate and store 10 000 000 objects/elements indexed i hesitate. Because i do not know how the extra memory requirements storing the bolean properties.
> 
> > 
> 
> > This is my datastructure and initialization right now.
> 
> > 
> 
> > How much space would it take if i added fibonaci,square and cubic booleans into the structure if the scope is one million elements/objects?
> 
> > 
> 
> > Would it save alot of space (and time?) if i stored colors as integers and used a lookup table at printout setting the color?
> 
> > 
> 
> > function arraysize()
> 
> > {
> 
> >    for ( i = -scope; i <= scope; i ++ )
> 
> >    { 
> 
> >       arr[i] =
> 
> >       {
> 
> >          count : i,
> 
> >          fcolor : 'black',
> 
> >          rheight : 100,
> 
> >          rwidth : 100,
> 
> >          rcolor : 'white',
> 
> >          prime : true
> 
> >       }
> 
> >    }
> 
> > }
> 
> 
> 
> Since the index of the array is the same as the count, do you need to have the property at all? Also, if the display properties are constant for this range, you could have a shared reference:
> 
> 
> 
> function arraysize(){
> 
>   var display = {
> 
>     fcolor : 'black',
> 
>     rheight : 100,
> 
>     rwidth : 100,
> 
>     rcolor : 'white'
> 
>   };
> 
> 
> 
>   for (var i = -scope; i <= scope; i++)
> 
>     arr[i] = {
> 
>       prime : true,
> 
>       display: display
> 
>     }
> 
> }
> 
> 
> 
> Are you using the properties of the numbers only to dictate how they will be displayed?

I think i will need the counter doing filter manipulations to print out subsets.
Otherwise i have to create another array to store the filtered subset.

Well width and height should probably not be there since the objects printed out are same size, but i do need rcolor and fcolor for each object, the rendering is layered, (sequential order) and i basicly go from most frequent to smallest frequent meaning that at user update of printout properties i actually must loop through all generating functions except for prime which is prestored and only need to be set.

If i add booleans for all properties i can remove the colorfield and set colors using a lookup table at printout but i am not sure what that does speedwise when running animate.

And i read that javascript may store 32 bit for each boolean value?
Right now the properties of the numbers only used to store colors, so the color field store odd,even,pos,neg,prime, square, cube and fibonacci in sequential order painting over previous stored value.

But i can see now that the chosen height and width probably should be set hardcoded by variable not in object.

But i will keep count for filtering at object level not in the loop and probably add a boolean called render.
But whether setting boolean properties or render square,cubic,fibonaci on the fly i am not sure, which is more fast or elegant. Because there could be other properties or sequenses needed to be added and the object grow out of memory.




but since i actually do not store each instance of the square, fibonaci and cubic numbers bu

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


Thread

Boolean spacerequirment in javascript jonas.thornvall@gmail.com - 2014-04-06 21:58 -0700
  Re: Boolean spacerequirment in javascript jonas.thornvall@gmail.com - 2014-04-06 22:10 -0700
  Re: Boolean spacerequirment in javascript "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-04-07 00:42 -0700
    Re: Boolean spacerequirment in javascript jonas.thornvall@gmail.com - 2014-04-07 01:23 -0700
      Re: Boolean spacerequirment in javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-04-07 13:40 +0200
        Re: Boolean spacerequirment in javascript Christoph Michael Becker <cmbecker69@arcor.de> - 2014-04-07 13:52 +0200
          Re: Boolean spacerequirment in javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-04-07 14:15 +0200
          Re: Boolean spacerequirment in javascript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-04-07 15:11 +0200
            Re: Boolean spacerequirment in javascript Tim Streater <timstreater@greenbee.net> - 2014-04-07 16:22 +0000

csiph-web