array of bits?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MM

    #1

    array of bits?

    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.
  • Paul Rubin

    #2
    Re: array of bits?

    MM <mm@newsgroups. com> writes:[color=blue]
    > 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.[/color]

    Use a normal list: [False, False, True, False, True, ... ] .

    Comment

    • Fredrik Lundh

      #3
      Re: array of bits?

      "MM" wrote:
      [color=blue]
      > 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.[/color]

      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>



      Comment

      • MM

        #4
        Re: array of bits?

        Thanks people. List it is. matthew.

        Comment

        Working...