Implementation of Array[Boolean]

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Implementation of Array[Boolean]

Peter Wolf
Hello, does anyone know how Array[Boolean] is implemented?  

What is really in memory?  Does Scala represent each element as a separate byte and waste memory, or does it pack the bits and spend processing time accessing them?  What happens when you set of get an element?

Thanks
Peter

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Aw: [scala-user] Implementation of Array[Boolean]

Dennis Haupt-2
it's a native java array. how the jvm implements it.... good question
didn't check since java 1.6
 
Gesendet: Samstag, 04. März 2017 um 16:54 Uhr
Von: "Peter Wolf" <[hidden email]>
An: scala-user <[hidden email]>
Betreff: [scala-user] Implementation of Array[Boolean]
Hello, does anyone know how Array[Boolean] is implemented?  
 
What is really in memory?  Does Scala represent each element as a separate byte and waste memory, or does it pack the bits and spend processing time accessing them?  What happens when you set of get an element?
 
Thanks
Peter

 

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Implementation of Array[Boolean]

Lieven Lemiengre
The smallest element of an array is a byte, the smallest directly addressable piece of memory.

If you want a more efficient memory representation you need to use a BitVector.

On Sat, Mar 4, 2017 at 5:05 PM, Dennis Haupt <[hidden email]> wrote:
it's a native java array. how the jvm implements it.... good question
didn't check since java 1.6
 
Gesendet: Samstag, 04. März 2017 um 16:54 Uhr
Von: "Peter Wolf" <[hidden email]>
An: scala-user <[hidden email]>
Betreff: [scala-user] Implementation of Array[Boolean]
Hello, does anyone know how Array[Boolean] is implemented?  
 
What is really in memory?  Does Scala represent each element as a separate byte and waste memory, or does it pack the bits and spend processing time accessing them?  What happens when you set of get an element?
 
Thanks
Peter

 

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Implementation of Array[Boolean]

Oliver Ruebenacker

     Hello,

  Note that the Scala compiler will translate scala.Boolean to Java's primitive boolean, if it can, otherwise to java.lang.Boolean. Array[boolean] is a byte per entry, but Array[java.lang.Boolean] is considerably more.

     Best, Oliver

On Tue, Mar 7, 2017 at 12:40 PM, Lieven Lemiengre <[hidden email]> wrote:
The smallest element of an array is a byte, the smallest directly addressable piece of memory.

If you want a more efficient memory representation you need to use a BitVector.

On Sat, Mar 4, 2017 at 5:05 PM, Dennis Haupt <[hidden email]> wrote:
it's a native java array. how the jvm implements it.... good question
didn't check since java 1.6
 
Gesendet: Samstag, 04. März 2017 um 16:54 Uhr
Von: "Peter Wolf" <[hidden email]>
An: scala-user <[hidden email]>
Betreff: [scala-user] Implementation of Array[Boolean]
Hello, does anyone know how Array[Boolean] is implemented?  
 
What is really in memory?  Does Scala represent each element as a separate byte and waste memory, or does it pack the bits and spend processing time accessing them?  What happens when you set of get an element?
 
Thanks
Peter

 

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Oliver Ruebenacker
Senior Software Engineer, Diabetes Portal, Broad Institute

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Implementation of Array[Boolean]

Nils Kilden-Pedersen
In reply to this post by Peter Wolf

As others have already mentioned, Array[Boolean] is a native Java boolean[], which uses a byte per entry.

The JDK has java.util.BitSet which is much more memory efficient.


On Sat, Mar 4, 2017 at 9:54 AM, Peter Wolf <[hidden email]> wrote:
Hello, does anyone know how Array[Boolean] is implemented?  

What is really in memory?  Does Scala represent each element as a separate byte and waste memory, or does it pack the bits and spend processing time accessing them?  What happens when you set of get an element?

Thanks
Peter

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Aw: Re: [scala-user] Implementation of Array[Boolean]

Dennis Haupt-2
cala also has a bitset, but i forgot what the difference was. 
 
Gesendet: Mittwoch, 15. März 2017 um 16:56 Uhr
Von: "Nils Kilden-Pedersen" <[hidden email]>
An: "Peter Wolf" <[hidden email]>
Cc: scala-user <[hidden email]>
Betreff: Re: [scala-user] Implementation of Array[Boolean]

As others have already mentioned, Array[Boolean] is a native Java boolean[], which uses a byte per entry.

The JDK has java.util.BitSet which is much more memory efficient.

 
On Sat, Mar 4, 2017 at 9:54 AM, Peter Wolf <[hidden email]> wrote:
Hello, does anyone know how Array[Boolean] is implemented?  
 
What is really in memory?  Does Scala represent each element as a separate byte and waste memory, or does it pack the bits and spend processing time accessing them?  What happens when you set of get an element?
 
Thanks
Peter

 

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

 

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...