Here is a class I wrote to help myself keep track of my ObjectID's and keep a pool of them avalible for dynamicaly created this also allows for the reuse of id's very helpfull in multiplayer situations where the server is most difinatly going to need to reuse id's. The use is simple and can help break up id's by using multiple. it iven provides feedback if you have overused your pool of id's. you simply set a min and max on init and it does the rest you request a new id. when done with it release it back to the pool.
Public Class IDPooler
#Region " Declerations "
Private m_sMin As Single
Private m_sMax As Single
Private m_queue As System.Collections.Queue
#End Region
#Region " Properties "
Public ReadOnly Property IDSAvalible() As Boolean
Get
If m_queue.Count = 0 Then
Return False
Else
Return True
End If
End Get
End Property
#End Region
Public Sub New(ByVal Min As Single, ByVal Max As Single)
m_sMin = Min
m_sMax = Max
m_queue = New System.Collections.Queue(Max - Min)
For icount As Single = Min To Max
m_queue.Enqueue(icount)
Next
End Sub
#Region " Public Methods "
Public Function GetNextID() As Single
Dim sReturn As Single = m_queue.Dequeue
Return sReturn
End Function
Public Sub ReleaseID(ByVal id As Single)
m_queue.Enqueue(id)
End Sub
#End Region
End Class
Thanks,
Terry