Click here to Skip to main content
15,916,378 members
Home / Discussions / C#
   

C#

 
QuestionFill a dataset from different resource? Pin
Anonymous9-Mar-05 13:44
Anonymous9-Mar-05 13:44 
AnswerRe: Fill a dataset from different resource? Pin
Kodanda Pani9-Mar-05 22:52
Kodanda Pani9-Mar-05 22:52 
Questiondata set file list if exist???? Pin
Anonymous9-Mar-05 13:03
Anonymous9-Mar-05 13:03 
AnswerRe: data set file list if exist???? Pin
Christian Graus9-Mar-05 16:54
protectorChristian Graus9-Mar-05 16:54 
GeneralRe: data set file list if exist???? Pin
lornej10-Mar-05 4:21
lornej10-Mar-05 4:21 
GeneralRe: data set file list if exist???? Pin
Christian Graus10-Mar-05 9:38
protectorChristian Graus10-Mar-05 9:38 
GeneralCalculations Pin
Robske9-Mar-05 12:55
Robske9-Mar-05 12:55 
GeneralRe: Calculations Pin
Robert Rohde9-Mar-05 21:02
Robert Rohde9-Mar-05 21:02 
Hi,

I dont know if it is the optimal solution but it should work:

public struct Match 
{
	public int Team1;
	public int Team2;

	public Match(int t1, int t2)
	{
		Team1 = t1;
		Team2 = t2;
	}
}

object dummy = new object();

int teamsCount = 200;
ArrayList matchesList = GetMatches(teamsCount); //create list of matches to be done
Hashtable tokenMatches = new Hashtable();
for (int i = 1; i < teamsCount; i++) 
{
	ArrayList matchesInRound = new ArrayList();
	Hashtable tokenTeams = new Hashtable();
	foreach (Match match in matchesList) 
	{
		if (!tokenMatches.ContainsKey(match) 
			&& !tokenTeams.ContainsKey(match.Team1) 
			&& !tokenTeams.ContainsKey(match.Team2))
		{
			matchesInRound.Add(match);
			tokenMatches.Add(match, dummy);
			tokenTeams.Add(match.Team1, dummy);
			tokenTeams.Add(match.Team2, dummy);
		}
	}

	//Round ready
	Console.WriteLine("Round " + i + ": ");
	foreach (Match match in matchesInRound) 
	{
		Console.WriteLine("   " + match.Team1 + "-" + match.Team2);
	}
}



Its not very elegant. Its up to you to make it clean. I used Hashtables because they provide a rather fast lookup. I think up to about 100 teams should be no problem.
GeneralComboBox Help Pin
Ctwizzy9-Mar-05 12:54
Ctwizzy9-Mar-05 12:54 
GeneralHelp on Context Sensitive Help Pin
LannieK9-Mar-05 10:41
LannieK9-Mar-05 10:41 
GeneralThreads Pin
Anonymous9-Mar-05 9:11
Anonymous9-Mar-05 9:11 
GeneralRe: Threads Pin
TylerBrinks9-Mar-05 10:20
TylerBrinks9-Mar-05 10:20 
GeneralRe: Threads Pin
TylerBrinks9-Mar-05 10:23
TylerBrinks9-Mar-05 10:23 
GeneralRe: Threads Pin
El'Cachubrey9-Mar-05 20:09
El'Cachubrey9-Mar-05 20:09 
GeneralPROBLEM: Mouse Navigation with embedded browser control Pin
AnzelVincir9-Mar-05 8:18
AnzelVincir9-Mar-05 8:18 
QuestionAccess to HTML data via COM with C#? Pin
Pikebu9-Mar-05 7:00
Pikebu9-Mar-05 7:00 
AnswerRe: Access to HTML data via COM with C#? Pin
Heath Stewart9-Mar-05 7:55
protectorHeath Stewart9-Mar-05 7:55 
QuestionIs it possible for me using session variables into a class? Pin
see079-Mar-05 6:37
see079-Mar-05 6:37 
AnswerRe: Is it possible for me using session variables into a class? Pin
TylerBrinks9-Mar-05 10:32
TylerBrinks9-Mar-05 10:32 
GeneralRe: Is it possible for me using session variables into a class? Pin
see079-Mar-05 12:09
see079-Mar-05 12:09 
GeneralRe: Is it possible for me using session variables into a class? Pin
Andy Brummer9-Mar-05 12:48
sitebuilderAndy Brummer9-Mar-05 12:48 
GeneralRe: Is it possible for me using session variables into a class? Pin
see079-Mar-05 12:53
see079-Mar-05 12:53 
GeneralPrinting Problem Pin
GoodQuestion9-Mar-05 5:35
GoodQuestion9-Mar-05 5:35 
QuestionShow 1st instance of application when starting 2nd instance? Pin
Kasdoffe9-Mar-05 5:22
Kasdoffe9-Mar-05 5:22 
AnswerRe: Show 1st instance of application when starting 2nd instance? Pin
TylerBrinks9-Mar-05 6:25
TylerBrinks9-Mar-05 6:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.