473,388 Members | 1,215 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

array of bits?

MM
Hi,

What is the best structure/way to create an array of bits (actually
true/false flags) of an arbitrary length ranging from about 20 upto
about 500. Speed of access more of an issue than compactness.

eg:
[0] 0
[1] 0
[2] 1
[3] 0
[4] 1
....
[n] 0
etc.

Thanks for your input and advice. matthew.
Jul 18 '05 #1
3 1536
MM <mm@newsgroups.com> writes:
What is the best structure/way to create an array of bits (actually
true/false flags) of an arbitrary length ranging from about 20 upto
about 500. Speed of access more of an issue than compactness.


Use a normal list: [False, False, True, False, True, ... ] .
Jul 18 '05 #2
"MM" wrote:
What is the best structure/way to create an array of bits (actually true/false flags) of an
arbitrary length ranging from about 20 upto about 500. Speed of access more of an issue than
compactness.

eg:
[0] 0
[1] 0
[2] 1
[3] 0
[4] 1
...
[n] 0
etc.


if you need a list of flags, use a list of flags:

[False] * 500

(compared to a bit array, you'll waste a whopping 31 bits per flag, but
unless you plan to use tens of thousands of lists, that shouldn't be much
of a problem)

</F>

Jul 18 '05 #3
MM
Thanks people. List it is. matthew.
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: Scott Kelley | last post by:
Is there a way to reset all elements of an array with a single instruction? I want to set all elements to zero. Currently looping to do so. thx, Scott Kelley
5
by: Darius Fatakia | last post by:
I feel like I might be overlooking something obvious, but... I want to store an array of bits (0's and 1's) in the cheapest possible way. The array might be 1,000 to 10,000 elements long. What...
3
by: Pablo Gutierrez | last post by:
I have a C# method that reads Binary data (BLOB type) from a database and returns the data an array of bytes (i.e byte outbyte = new byte;). The BLOB column is saved into the database by a C...
32
by: Joe Rattz | last post by:
Hmmm, I wrote the following code. I want an array of bools and I want to intialize them to false. bool bits = new bool; foreach(bool bit in bits) { bit = false; } The compiler complains...
15
by: Kueishiong Tu | last post by:
How do I convert a Byte array (unsigned char managed) to a char array(unmanaged) with wide character taken into account?
4
by: Lance | last post by:
I have an array of bytes that I need to convert into an array of Integers. But, the number of bits per value in the Byte array is not necessarily divisible by 8 (although it will never exceed...
4
by: msosno01 | last post by:
I have Java client that connects to C++ server. The client sends integer in binary using DataOutputStream write function. I am reading these data into buffer. I have to convert this buffer back...
12
by: rajus | last post by:
I want to store the (x,y) coordinates of about 10,000 points in a 2D array.How can I store them and retrieve them later?
6
by: Active8 | last post by:
Hi: This prob "magically" stopped and I'm not sure if I can recreate it, but thought I'd share it and maybe learn something. #include "stdafx.h" #include <stdlib.h> #include <math.h>...
3
by: strikeforce299 | last post by:
I am trying to write a program that gets a 8 bit binary number from the user and converts it to the equivalent decimal and display on screen. i have it working but the user has to enter each bit...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.