vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
TOP-Angebot: 17 bzw. 24 Entwickler-Vollversionen zum unschlagbaren Preis!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Allgemeine Diskussionen
Re: Warum Speicherbedarf für boolean 2 bytes  
Autor: Mahobi
Datum: 09.07.04 12:47

Hi @ all,

So, hier der Code:

Zuerst die Klasse clsBitArray
Option Explicit
 
Private Const cLongBits As Long = 32
Private Const cLongMaxIndex As Long = cLongBits - 1
 
Private pBits() As Long
Private pBitVal(0 To cLongMaxIndex) As Long
Private pBitValNot(0 To cLongMaxIndex) As Long
Private pCount As Long
Private i As Long
 
 
Private Sub Class_Initialize()
  pBitVal(0) = 1
  For i = 1 To cLongMaxIndex - 1
    pBitVal(i) = pBitVal(i - 1) * 2
  Next i
  pBitVal(cLongMaxIndex) = &H80000000
 
  For i = 0 To cLongMaxIndex
    pBitValNot(i) = Not pBitVal(i)
  Next i
 
  Bits = cLongBits
End Sub
 
Public Property Get Bits() As Long
  Bits = pCount
End Property
 
Public Property Let Bits( _
    ByVal Value As Long)
 
  pCount = Value
  i = (pCount - 1&) \ cLongBits
  ReDim Preserve pBits(0 To i)
End Property
 
Public Property Get Bit( _
      ByVal Index As Long) As Boolean
 
  Bit = CBool(pBits(Index \ cLongBits) And _
      pBitVal(Index And cLongMaxIndex))
End Property
 
Public Property Let Bit( _
    ByVal Index As Long, _
    ByVal Flag As Boolean)
 
  i = Index \ cLongBits
  If Flag Then
    pBits(i) = pBits(i) Or _
        pBitVal(Index And cLongMaxIndex)
  Else
    pBits(i) = pBits(i) And _
        pBitValNot(Index And cLongMaxIndex)
  End If
End Property
 
 
Public Sub Clear()
  i = (pCount - 1&) \ cLongBits
  ReDim pBits(0 To i)
End Sub
 
Public Property Get ToString() As String
  ToString = String$(pCount, "0")
  For i = 0 To pCount - 1
    If Bit(i) Then _
        Mid$(ToString, pCount - i, 1) = "1"
  Next i
End Property
Und hier der Code für die Funktion:
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
 
Private Sub GetPrim()
Dim i As Long, bis As Long
Dim currentPrim As Long, viel As Long
Dim ColCount As Long
Dim intervallAnfang As Long
Dim ende As Long
Dim lstart As Long, lende As Long
Dim sOut As String
Dim bitPrim As clsBitArray
 
Set bitPrim = New clsBitArray
 
 
  bis = Text1.Text - 1
 
  lstart = GetTickCount
 
  bitPrim.Bits = bis
 
 
  currentPrim = 2
  ende = (bis + 1) / 2
  For currentPrim = 2 To ende
    viel = currentPrim + currentPrim 'Vielfache initialisieren
 
    If bitPrim.Bit(currentPrim) = False Then
      For i = currentPrim * 2 To bis Step currentPrim
        bitPrim.Bit(i) = True
 
      Next i
    End If
 
  Next currentPrim
 
  lende = GetTickCount
 
  sOut = "Dauer der Berechnung: " & lende - lstart & "ms" & vbCrLf
 
  MsgBox sOut
 
End Sub
So, das wärs. Muss dazu sagen, dass die Klasse nicht von mir stammt, weiß im Moment aber nicht mehr von wo.

Gruß
Mahobi
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Warum Speicherbedarf für boolean 2 bytes 1.772hobby_programmer03.07.04 23:34
Re: Warum Speicherbedarf für boolean 2 bytes 1.237JennyB04.07.04 09:07
Re: Warum Speicherbedarf für boolean 2 bytes 1.214hobby_programmer04.07.04 18:15
Re: Warum Speicherbedarf für boolean 2 bytes 1.389E704.07.04 18:18
Re: Warum Speicherbedarf für boolean 2 bytes 1.219LonelySuicide66604.07.04 21:59
Re: Warum Speicherbedarf für boolean 2 bytes 1.148hobby_programmer04.07.04 22:01
Re: Warum Speicherbedarf für boolean 2 bytes 1.173E705.07.04 18:36
Re: Warum Speicherbedarf für boolean 2 bytes 1.073LonelySuicide66606.07.04 17:02
Re: Warum Speicherbedarf für boolean 2 bytes 1.571ModeratorMartoeng05.07.04 19:43
Re: Warum Speicherbedarf für boolean 2 bytes 1.146E705.07.04 20:31
Re: Warum Speicherbedarf für boolean 2 bytes 1.151ModeratorMartoeng05.07.04 21:03
Re: Warum Speicherbedarf für boolean 2 bytes 1.161Snof06.07.04 00:03
Re: Warum Speicherbedarf für boolean 2 bytes 1.141ModeratorMartoeng06.07.04 09:49
Was ich mir vorstellen könnte...1.129ModeratorMartoeng05.07.04 19:51
Re: Was ich mir vorstellen könnte...1.043hobby_programmer06.07.04 15:39
Re: Was ich mir vorstellen könnte...1.055LonelySuicide66606.07.04 17:05
Re: Was ich mir vorstellen könnte...1.147E706.07.04 19:22
Re: Was ich mir vorstellen könnte...1.048LonelySuicide66606.07.04 21:12
Re: Warum Speicherbedarf für boolean 2 bytes 1.185Mr. Fox07.07.04 09:11
Re: Warum Speicherbedarf für boolean 2 bytes 1.081Mahobi08.07.04 11:24
Re: Warum Speicherbedarf für boolean 2 bytes 1.045hobby_programmer08.07.04 13:25
Re: Warum Speicherbedarf für boolean 2 bytes 1.150Mahobi08.07.04 14:11
Re: Warum Speicherbedarf für boolean 2 bytes 1.000hobby_programmer08.07.04 17:50
Re: Warum Speicherbedarf für boolean 2 bytes 989Mahobi09.07.04 08:53
Re: Warum Speicherbedarf für boolean 2 bytes 1.016ModeratorMartoeng09.07.04 09:34
Re: Warum Speicherbedarf für boolean 2 bytes 974Mahobi09.07.04 12:21
Re: Warum Speicherbedarf für boolean 2 bytes 984Mr. Fox08.07.04 20:34
Re: Warum Speicherbedarf für boolean 2 bytes 1.122Mahobi09.07.04 12:47
Re: Warum Speicherbedarf für boolean 2 bytes 1.145Mahobi09.07.04 18:15
Re: Warum Speicherbedarf für boolean 2 bytes 1.051Mahobi09.07.04 19:11
Re: Warum Speicherbedarf für boolean 2 bytes 1.071hobby_programmer09.07.04 22:37
Meine Zahlen1.052Snof10.07.04 01:53
groooßer Fehler.1.053Snof10.07.04 03:07
Re: Warum Speicherbedarf für boolean 2 bytes 1.031Mahobi10.07.04 00:47
Re: Warum Speicherbedarf für boolean 2 bytes 977hobby_programmer10.07.04 13:11
Re: Warum Speicherbedarf für boolean 2 bytes 1.018E710.07.04 14:57

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel