kleiner wettbewerb sucht bewertungen

Übersicht Sonstiges Projekte

Neue Antwort erstellen

Wessen code ist nun besser?
da_poller 45% 45% 5 Stimmen
Meoqan 54% 54% 6 Stimmen
Insgesamt 11 Stimmen
 

da_poller

Betreff: kleiner wettbewerb sucht bewertungen

BeitragSo, Okt 12, 2008 22:02
Antworten mit Zitat
Benutzer-Profile anzeigen
eine liste von datenfeldern(eher zeilen) die unterschiedlich groß sind..

gelistet in einem index(einem type)

NICHT type\array[3]
NICHT DIM(dimension1,dimension2)

sondern in der art von type\subtype\wert diese solte dynamisch sein.

2 eher unkonventionelle methoden aber was ist besser?

Die Regeln:
-keine DIM oder Blitzarray erlaubt
-keine Bank
-keine tiefschläge Smile

noch keine DELETE & INSERT funktion enthalten. (kommt noch) <-was das ganze erst richtig dynamisch macht

ps: wir wissen das wir irre sind!


mfg Meoqan & da_poller


da_poller:
Code: [AUSKLAPPEN]
Type child
   Field id
   Field wert
   Field pos
End Type

Type stage
   Field id
   Field size
   Field x.child
End Type
Global stage.stage

start=MilliSecs()
For x=1 To 5
   mydim_create(x,5)
Next

For y=1 To 5
   mydim_write(y,1,Rand(1,100))
   mydim_write(y,5,Rand(1,100))
Next

For stage\x.child = Each child
   xxx$=": "
   For x=1 To stage\size
      xxx$=xxx$+ mydim_read$(stage\x\id,x)+": "
   Next
   Print stage\id+"=>"+xxx$
Next

End


;#########################################################################

Function mydim_create(mydim_id,mydim_size)
   
   stage = New stage
   stage\id=mydim_id
   stage\size=mydim_size
   mydim_newdim(mydim_id,mydim_size)
   
End Function

Function mydim_newdim(mydim_id,mydim_size)
   
   For mydim=1 To mydim_size
      stage\x = New child
      stage\x\id=mydim_id
      stage\x\wert=0
      stage\x\pos=mydim
   Next
   
End Function

Function mydim_write(mydim_id,mydim_pos,mydim_wert)
   
   For stage\x.child=Each child
      If stage\x\id=mydim_id:If stage\x\pos=mydim_pos Then
            stage\x\wert=mydim_wert
      EndIf:EndIf
   Next
   
End Function

Function mydim_read$(mydim_id,mydim_pos)
   
   For stage\x.child=Each child
      If stage\x\id=mydim_id:If stage\x\pos=mydim_pos Then
            Return stage\x\wert
      EndIf:EndIf
   Next
   
End Function


Meoqan:

Code: [AUSKLAPPEN]
Type subtype
   Field wert
End Type
Global subtype.subtype
Type feld
   Field x.subtype
   Field handl
   
   Field wert
End Type
Global feld.feld


For x=1 To 2
   feld = New feld
   For y=4 To 5
      feld\handl = new_subtype(feld\handl)
      feld\x\wert = y
   Next
   feld\wert=x
Next

For feld = Each feld
   Print feld\wert
   For blubb = 0  To max_subtype(feld\handl)
      mount_subtype(blubb,feld\handl)
      Print feld\x\wert
   Next
Next

WaitKey()

;#########################################################################

Type index
   Field max
   Field hndl
End Type
Global index.index

Function new_subtype(hndl)
   If hndl Then
      index = Object.index(hndl)
      subtype = New subtype
      Insert subtype After Object.subtype(index\hndl)
      index\max=index\max+1
      feld\x = Object.subtype(Handle(subtype))
      Return Handle(index)
   Else
      index = New index
      feld\x = New subtype
      index\max = 0
      index\hndl=Handle(feld\x)
      Return Handle(index)
   EndIf
End Function

Function max_subtype(hndl)
   index = Object.index(hndl)
   Return index\max
End Function

Function mount_subtype(ID,hndl)
   index = Object.index(hndl)
   feld\x = Object.subtype(index\hndl)
   If ID > 0 Then
      For x = 1 To ID
         feld\x = After feld\x
      Next
   EndIf
End Function


die umfrage läuft genau 30 tage bitte um FAIRE und Konstruktives antworten.. jederlei fragen können hier gerne gestellt werden(zu beiden codes) wir werden uns schnellst möglcih um eine antwort bemühen..

zu guter letzt: Meoqan war echt lustig das als mini-wettbewerb aufzuziehen möge der bessere gewinnen!![/quote]

edit: sollte es das falsche forum sein bitte verschieben..

Xeres

Moderator

BeitragSo, Okt 12, 2008 22:49
Antworten mit Zitat
Benutzer-Profile anzeigen
Um ehrlich zu sein scheint mir die Bedienung von beidem nicht besonders Elegant.
- Wie viele Dimensionen kann man damit erzeugen?
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)

Meoqan

BeitragSo, Okt 12, 2008 23:32
Antworten mit Zitat
Benutzer-Profile anzeigen
elegant wäre wenn das BB von alleine könnte...


mal schauen... *g*


Code: [AUSKLAPPEN]

Type subtype5
   Field wert$
End Type
Global subtype5.subtype5

Type subtype4
   Field subtype5.subtype5
   Field handl
End Type
Global subtype4.subtype4

Type subtype3
   Field subtype4.subtype4
   Field handl
End Type
Global subtype3.subtype3

Type subtype2
   Field subtype3.subtype3
   Field handl
End Type
Global subtype2.subtype2

Type subtype1
   Field subtype2.subtype2
   Field handl
End Type
Global subtype1.subtype1

Type feld
   Field subtype1.subtype1
   Field handl
   Field wert
End Type
Global feld.feld



For y1=0 To 9
   feld = New feld
   For y2=0 To 9
      feld\handl = new_subtype1(feld\handl)
      For y3=0 To 9
         feld\subtype1\handl = new_subtype2(feld\subtype1\handl)
         For y4=0 To 9
            feld\subtype1\subtype2\handl = new_subtype3(feld\subtype1\subtype2\handl)
            For y5=0 To 9
               feld\subtype1\subtype2\subtype3\handl = new_subtype4(feld\subtype1\subtype2\subtype3\handl)
               For y6=0 To 9
                  feld\subtype1\subtype2\subtype3\subtype4\handl = new_subtype5(feld\subtype1\subtype2\subtype3\subtype4\handl)
                  
                  feld\subtype1\subtype2\subtype3\subtype4\subtype5\wert = Str(" " +y1+y2+y3+y4+y5+y6)
                  
               Next
            Next
         Next
      Next
   Next
Next


For feld = Each feld
   For blubb1 = 0  To max_subtype1(feld\handl)
      mount_subtype1(blubb1,feld\handl)
      For blubb2 = 0  To max_subtype2(feld\subtype1\handl)
         mount_subtype2(blubb2,feld\subtype1\handl)
         For blubb3 = 0  To max_subtype3(feld\subtype1\subtype2\handl)
            mount_subtype3(blubb3,feld\subtype1\subtype2\handl)
            For blubb4 = 0  To max_subtype4(feld\subtype1\subtype2\subtype3\handl)
               mount_subtype4(blubb4,feld\subtype1\subtype2\subtype3\handl)
               For blubb5 = 0  To max_subtype5(feld\subtype1\subtype2\subtype3\subtype4\handl)
                  mount_subtype5(blubb5,feld\subtype1\subtype2\subtype3\subtype4\handl)
                  
                  Print feld\subtype1\subtype2\subtype3\subtype4\subtype5\wert
                  
               Next
            Next
         Next
      Next
   Next
Next


WaitKey()

;#########################################################################


Type index
   Field max
   Field hndl
End Type
Global index.index

;______________________________

Function new_subtype1(hndl)
   If hndl Then
      index = Object.index(hndl)
      subtype1 = New subtype1
      Insert subtype1 After Object.subtype1(index\hndl)
      index\max=index\max+1
      feld\subtype1 = Object.subtype1(Handle(subtype1))
      Return Handle(index)
   Else
      index = New index
      feld\subtype1 = New subtype1
      index\max = 0
      index\hndl=Handle(feld\subtype1)
      Return Handle(index)
   EndIf
End Function

Function max_subtype1(hndl)
   index = Object.index(hndl)
   Return index\max
End Function

Function mount_subtype1(ID,hndl)
   index = Object.index(hndl)
   feld\subtype1 = Object.subtype1(index\hndl)
   If ID > 0 Then
      For x = 1 To ID
         feld\subtype1 = After feld\subtype1
      Next
   EndIf
End Function

;______________________________
;______________________________

Function new_subtype2(hndl)
   If hndl Then
      index = Object.index(hndl)
      subtype2 = New subtype2
      Insert subtype2 After Object.subtype2(index\hndl)
      index\max=index\max+1
      feld\subtype1\subtype2 = Object.subtype2(Handle(subtype2))
      Return Handle(index)
   Else
      index = New index
      feld\subtype1\subtype2 = New subtype2
      index\max = 0
      index\hndl=Handle(feld\subtype1\subtype2)
      Return Handle(index)
   EndIf
End Function

Function max_subtype2(hndl)
   index = Object.index(hndl)
   Return index\max
End Function

Function mount_subtype2(ID,hndl)
   index = Object.index(hndl)
   feld\subtype1\subtype2 = Object.subtype2(index\hndl)
   If ID > 0 Then
      For x = 1 To ID
         feld\subtype1\subtype2 = After feld\subtype1\subtype2
      Next
   EndIf
End Function

;______________________________
;______________________________

Function new_subtype3(hndl)
   If hndl Then
      index = Object.index(hndl)
      subtype3 = New subtype3
      Insert subtype3 After Object.subtype3(index\hndl)
      index\max=index\max+1
      feld\subtype1\subtype2\subtype3 = Object.subtype3(Handle(subtype3))
      Return Handle(index)
   Else
      index = New index
      feld\subtype1\subtype2\subtype3 = New subtype3
      index\max = 0
      index\hndl=Handle(feld\subtype1\subtype2\subtype3)
      Return Handle(index)
   EndIf
End Function

Function max_subtype3(hndl)
   index = Object.index(hndl)
   Return index\max
End Function

Function mount_subtype3(ID,hndl)
   index = Object.index(hndl)
   feld\subtype1\subtype2\subtype3 = Object.subtype3(index\hndl)
   If ID > 0 Then
      For x = 1 To ID
         feld\subtype1\subtype2\subtype3 = After feld\subtype1\subtype2\subtype3
      Next
   EndIf
End Function

;______________________________

;______________________________

Function new_subtype4(hndl)
   If hndl Then
      index = Object.index(hndl)
      subtype4 = New subtype4
      Insert subtype4 After Object.subtype4(index\hndl)
      index\max=index\max+1
      feld\subtype1\subtype2\subtype3\subtype4 = Object.subtype4(Handle(subtype4))
      Return Handle(index)
   Else
      index = New index
      feld\subtype1\subtype2\subtype3\subtype4 = New subtype4
      index\max = 0
      index\hndl=Handle(feld\subtype1\subtype2\subtype3\subtype4)
      Return Handle(index)
   EndIf
End Function

Function max_subtype4(hndl)
   index = Object.index(hndl)
   Return index\max
End Function

Function mount_subtype4(ID,hndl)
   index = Object.index(hndl)
   feld\subtype1\subtype2\subtype3\subtype4 = Object.subtype4(index\hndl)
   If ID > 0 Then
      For x = 1 To ID
         feld\subtype1\subtype2\subtype3\subtype4 = After feld\subtype1\subtype2\subtype3\subtype4
      Next
   EndIf
End Function

;______________________________
;______________________________

Function new_subtype5(hndl)
   If hndl Then
      index = Object.index(hndl)
      subtype5 = New subtype5
      Insert subtype5 After Object.subtype5(index\hndl)
      index\max=index\max+1
      feld\subtype1\subtype2\subtype3\subtype4\subtype5 = Object.subtype5(Handle(subtype5))
      Return Handle(index)
   Else
      index = New index
      feld\subtype1\subtype2\subtype3\subtype4\subtype5 = New subtype5
      index\max = 0
      index\hndl=Handle(feld\subtype1\subtype2\subtype3\subtype4\subtype5)
      Return Handle(index)
   EndIf
End Function

Function max_subtype5(hndl)
   index = Object.index(hndl)
   Return index\max
End Function

Function mount_subtype5(ID,hndl)
   index = Object.index(hndl)
   feld\subtype1\subtype2\subtype3\subtype4\subtype5 = Object.subtype5(index\hndl)
   If ID > 0 Then
      For x = 1 To ID
         feld\subtype1\subtype2\subtype3\subtype4\subtype5 = After feld\subtype1\subtype2\subtype3\subtype4\subtype5
      Next
   EndIf
End Function

;______________________________



so hab mal 6 dimensionen erstellt *g* ich denke es geht noch viel mehr aber wer braucht das schon Rolling Eyes
meine codes sind die essenz des bössen. nicht du veränderst meine codes sondern meine codes verändern dich!

Xeres

Moderator

BeitragMo, Okt 13, 2008 14:02
Antworten mit Zitat
Benutzer-Profile anzeigen
Mit Bedienung wollte ich eher auf den Zugriff/Verarbeitung anspielen; "Per Hand" auf die Types zuzugreifen um an bestimmte Werte ran zu kommen fänd' ich eher hinderlich - mydim_write() sieht noch am ehesten wie etwas aus, mit dem man Arbeiten kann.
Und um wirklich dynamisch zu sein, darf man nicht Subtypes hinzufügen müssen um mehrdimensional zu agieren.
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)

Neue Antwort erstellen


Übersicht Sonstiges Projekte

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group