It might be easier to maintain a single list of your FileStrc objects and have a couple of dictionaries that maintain the key / object value (or key / index values).
I think this is exactly what I'm doing (I hope I didn't missunderstood).
I have only
one array where I store the FileStrc Classes (no sorting done there) and
I have an array which contains the ALIndex Classes which in turn contains
the index values ordered with help of the IComparer which is also stored in the ALIndex Class
(Each ALIndex in the Indeces array has an own sorting scheme and indexlist).
The only difference is that I'm using a List(Of 32) Class instead of a dictionary.
I'm assuming you mean a dictionary(Of Int32, Int32) with the Key being 0..1..2..3..n and
the Value being the index values to the content array,
but then again it would make things more complicated,
since when adding an item I would have to insert the item
and
edit the Key entries in it so there aren't any duplicates.
So I guess I didn't understand you there.
How large a collection of objects do you have? Does an unsorted list of keys actually perform too slow and you really need them to be sorted or are you attempting to prevent future slowdowns?
Mostly there are only a few objects in the list (around 20 or so) but there are some cases it might go up to 600 objects.
It took about 6 seconds to add 1280 Files to the Array (sorted) and 32 seconds without sorting.
(Although it was not just adding the FileStrc Classes to the array, some other operations were involved too)
The FileStrc Class looks like this:
Visual Basic:
#Region "Var Structures"
Class FileStrc
Public FilePath As New FilePathStrc
Public OldFilePath As New FilePathStrc
Public ProcessedOn As New DateTime
Public DBInfo As New DBStrc
Public MyList As New MyListStrc
Public Info As New FileInfoStrc
Public State As New StateStrc
End Class
Class DBStrc
Public Response As Boolean
Public FId As Int32
Public EId As Int32
Public AId As Int32
Public GId As Int32
Public LId As Int32
Public State As UInt16
Public GroupLong As String
Public GroupShort As String
Public EpNo As String
Public EpName As New LanguageStrc
Public Type As String
Public SeriesName As New LanguageStrc
Public SeriesNameShort As String
Public SeriesNameOther As String
Public Synonym As String
End Class
Class LanguageStrc
Public English As String
Public Romaji As String
Public Kanji As String
End Class
Class FilePathStrc
Public Path As String
Public FileName As String
Public Property FilePath() As String
Get
Return Path & "\" & FileName
End Get
Set(ByVal NewPath As String)
Path = My.Computer.FileSystem.GetParentPath(NewPath)
FileName = My.Computer.FileSystem.GetName(NewPath)
End Set
End Property
End Class
Class MyListStrc
Public State As New MLStateEnum
Public Storage As String
Public Add As New AddEnum
Public Watched As Boolean
Public Source As String
Public Other As String
Public Vote As Single
End Class
Class FileInfoStrc
Public CreationDate As New DateTime
Public Duration As Double
Public App As String
Public Library As String
Public Extension As String
Public Size As UInt64
Public OverHead As Int32
Public Hashes As New HashesStrc
Public Title As String
Public Video As New VideoStrc
Public Audio As New System.Collections.ArrayList 'AudioStrc
Public DefaultAudio As Byte
Public Subtitles As New System.Collections.ArrayList ' SubtitleStrc
Public DefaultSubtitle As Byte
End Class
Class HashesStrc
Public crc As String
Public ed2k As String = ""
Public md5 As String
Public sha1 As String
Public tth As String
End Class
Class VideoStrc
Public Frames As Int32
Public Duration As Double
Public FPS As Single
Public Resolution As New Point
Public AspectRatio As New Point
Public Codec As New CodecStrc
Public Identifier As String
Public Size As Int32
Public Title As String
Public Chroma As String
Public Struc As String
Public Encoder As String
End Class
Class AudioStrc
Public Size As New Int32
Public Duration As Double
Public Language As String
Public Identifier As String
Public Channel As Int16
Public SamplingRate As Int32
Public Samples As Int32
Public Title As String
Public Mode As String
End Class
Class SubtitleStrc
Public Size As Int32
Public Language As String
Public Identifier As String
Public Title As String
End Class
Class CodecStrc
Public Name As String
Public Settings As String
Public Stats As String
End Class
Class StateStrc
Public Reason As String
Public State As New StateEnum
End Class
Public Enum AddEnum
NoAction
AddToMyList
InMyList
NotFound
End Enum
Public Enum StateEnum
UnProcessed = 0
Processing = 1
Processed = 2
Failed = 3
End Enum
Public Enum MLStateEnum
Unknown = 0
OnHDD = 1
OnCd = 2
Deleted = 3
Share = 4
Release = 5
End Enum
#End Region
I've fixed some bugs in my class and added some new functions/properties:
See Attachment (I also added a class to show how it works, just call Usage.DoStuff somewhere)