VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Seeding"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'Klasa Seeding
Private numLanes As Integer
Private laneOrder As Collection
Dim asw() As Swimmer
'-----
Public Function getSeeding() As Collection
End Function
'-----
Public Function getHeat() As Integer
End Function
'-----
Public Function getCount() As Integer
End Function
'-----
Public Sub seed()
End Sub
'-----
Public Function getSwimmers() As Collection
End Function
'-----
Public Function getHeats() As Integer
End Function
'-----
Private Function odd(n As Integer) As Boolean
 odd = (n \ 2) * 2 <> n
End Function
'-----
Public Function calcLaneOrder(lns As Integer) As Collection
  numLanes = lns
  ReDim lanes(numLanes) As Integer
  Dim i As Integer
  Dim mid As Integer, incr As Integer, ln As Integer
  mid = numLanes / 2
  If (odd(numLanes)) Then
    mid = mid + 1                 'Rozpocznij od środkowego toru
  End If
  incr = 1
  ln = mid
  For i = 1 To numLanes
    lanes(i) = ln
    ln = mid + incr
    incr = -incr
    If (incr > 0) Then
      incr = incr + 1
    End If
  Next i
  
  Set laneOrder = New Collection
  For i = 1 To numLanes
    laneOrder.Add lanes(i)
  Next i
  Set calcLaneOrder = laneOrder
End Function

Public Sub init(swmrs As Collection, lanes As Integer)
End Sub

Public Function sort(sw As Collection) As Collection
  ReDim asw(sw.count) As Swimmer
  Dim i As Integer, j As Integer, max As Integer
  Dim tmp As Swimmer

  max = sw.count
  For i = 1 To max
    Set asw(i) = sw(i)
  Next i
  For i = i To max
    For j = i To max
      If asw(i).getTime > asw(j).getTime Then
        Set tmp = asw(i)
        Set asw(j) = asw(i)
        Set asw(i) = tmp
      End If
    Next j
  Next i

  Set sw = Nothing
  Set sw = New Collection
  For i = 1 To max
    sw.Add asw(i)
  Next i
    
  Set sort = sw
End Function
