i don't know how but for weeks now i was using a HashSet<myObject>
collection of mainly strings members as i really though it's internally uses a builtin approach as dictionary to avoid duplicate items in a non KVP format of data(single columns)
my scenario is :
HashSet<myHddFolderPaths> UniqColleciton = new HashSet<myHddFolderPtahs>
int countRounds=0;
void addToCollection()
{
for(int i=0, i < UniqColleciton.Count; i++)
{
add some items to UniqColleciton via Directory.GetDirectories();
}
if(countRounds++ < Limit)
addToCollection()
}
this is a pattern for dir-walker i am building and this is only an example for a scenario when recurse of same data could not be avoided so i don't recall where i have read about it and thought, that by simply using a HashSet<T>
would "just take Care of business"
i haven't thought of the option it will allow duplicates but in this project i put it to a test and it did allow to my surprise to add an existing items so my work around is :
Dictionary<string, int> fiterAccesDeniedPaths = new Dictionary<string, int>();
Dictionary<string, int> fiterAccesiblePaths = new Dictionary<string, int>();
if (this.fiterAccesDeniedPaths.ContainsKey(e.Message)) continue;
if (this.fiterAccessiblePaths.ContainsKey(object.stringPathMember)) continue;
add to filters ; UniqColleciton.Add(myHddFolderPaths);
is there a better/more efficient approach for acomplishing this task ?
public class FolderPath
{
public string DriveL { get; set; }
public string FolderLevel { get; set; }
public string Path { get; set; }
public int Fsize { get; set; }
}
public class GenericUniqCollectionM<T> : HashSet<T>
{
public GenericUniqCollectionM():base()
{
}
}