Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class cListSet {
- const int DIVISIONS = 128;
- List<cListEntry>[] entries = new List<cListEntry>[DIVISIONS];
- public bool Add( cListEntry entry ) {
- int hash = entry.GetHashCode();
- if( entries[hash] == null ) {
- // no entry for this hash group exist, adding new
- entries[hash] = new List<cListEntry>();
- entries[hash].Add( entry );
- return true;
- } else {
- // at least the hash group exists
- List<cListEntry> group = entries[hash];
- int index = group.IndexOf(entry);
- if( index != -1 ) {
- // entry exists, update
- group[index].lastupdate = DateTime.Now;
- return false;
- } else {
- // entry does not exist, add
- group.Add( entry );
- return true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement