TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sin Yee
NA
145
74.7k
How to count the ocurrance for each items
Apr 8 2011 11:15 AM
Hey, now i doing the FP-tree , i need to count the ocurrences for each items.
i got try using sortedlist, but it give me error.
here is my coding:
private void FPConstruction()
{
HashSet<string> hsfP2 = new HashSet<string>(hsfP1);
HashSet<string> hsfP3 = new HashSet<string>();
List<string> storehsfP = new List<string>();
SortedList FPCount = new SortedList();
for (int i = 0; i < FPArray.Count; i++)
{
foreach (string k in FPArray[i].ToString().Split(' '))
{
hsfP3.Add(k);
}
var clone2 = new HashSet<string>(hsfP2);
hsfP2.IntersectWith(hsfP3);
foreach (string v in hsfP2)
{
storehsfP.Add(v);
}
hsfP2 = clone2;
hsfP3.Clear();
}
string[] FpStrArray = storehsfP.ToArray();
string[] FPArray2 = new string[FPArray.Count];
int[] lens1 = new int[FPArray.Count];
int indexs1 = 0;
foreach (string f in FPArray)
{
lens1[indexs1] = f.Replace(" ", "").Length;
indexs1++;
}
indexs1 = 0;
int indexs2 = 0;
string[] TemPlc = new string[lens1[0]];
foreach (string w in FpStrArray)
{
if (indexs2 < lens1[indexs1])
{
TemPlc[indexs2] = w;
indexs2++;
}
else
{
FPArray2[indexs1] = String.Join(" ", TemPlc);
indexs1++;
TemPlc = new string[lens1[indexs1]];
TemPlc[0] = w;
indexs2 = 1;
}
}
FPArray2[indexs1] = String.Join(" ", TemPlc);
string message3 = String.Join("\r\n", FPArray2);
DisplayResult.Clear();
DisplayResult.AppendText(message3);
}
hope someone can help me...thanks you so much.
Reply
Answers (
9
)
how to print values from a window form
How to count total item from two file