Click here to Skip to main content
15,905,875 members
Home / Discussions / C#
   

C#

 
GeneralRe: Visual studio 2010 C# identity without hyphen Pin
sdfsdfsdfewrew3feff23-Feb-15 2:09
sdfsdfsdfewrew3feff23-Feb-15 2:09 
GeneralRe: Visual studio 2010 C# identity without hyphen Pin
sdfsdfsdfewrew3feff1-Mar-15 5:10
sdfsdfsdfewrew3feff1-Mar-15 5:10 
QuestionConverting Alphabet to corresponding number Pin
Tetra104416-Feb-15 5:27
Tetra104416-Feb-15 5:27 
AnswerRe: Converting Alphabet to corresponding number Pin
Rob Philpott16-Feb-15 5:33
Rob Philpott16-Feb-15 5:33 
GeneralRe: Converting Alphabet to corresponding number Pin
Tetra104416-Feb-15 6:10
Tetra104416-Feb-15 6:10 
SuggestionRe: Converting Alphabet to corresponding number Pin
Richard Deeming16-Feb-15 8:29
mveRichard Deeming16-Feb-15 8:29 
GeneralRe: Converting Alphabet to corresponding number Pin
Rob Philpott16-Feb-15 9:28
Rob Philpott16-Feb-15 9:28 
GeneralRe: Converting Alphabet to corresponding number Pin
Wastedtalent19-Feb-15 4:55
professionalWastedtalent19-Feb-15 4:55 
AnswerRe: Converting Alphabet to corresponding number Pin
PIEBALDconsult16-Feb-15 5:47
mvePIEBALDconsult16-Feb-15 5:47 
GeneralRe: Converting Alphabet to corresponding number Pin
Tetra104416-Feb-15 6:12
Tetra104416-Feb-15 6:12 
AnswerRe: Converting Alphabet to corresponding number Pin
BillWoodruff16-Feb-15 12:59
professionalBillWoodruff16-Feb-15 12:59 
GeneralRe: Converting Alphabet to corresponding number Pin
Rob Philpott16-Feb-15 23:21
Rob Philpott16-Feb-15 23:21 
QuestionWhy is Array.Sort() slower if I use my own comparer? Pin
robinsc16-Feb-15 1:09
robinsc16-Feb-15 1:09 
AnswerRe: Why is Array.Sort() slower if I use my own comparer? Pin
Rob Philpott16-Feb-15 2:06
Rob Philpott16-Feb-15 2:06 
GeneralRe: Why is Array.Sort() slower if I use my own comparer? Pin
robinsc16-Feb-15 2:20
robinsc16-Feb-15 2:20 
GeneralRe: Why is Array.Sort() slower if I use my own comparer? Pin
Rob Philpott16-Feb-15 2:26
Rob Philpott16-Feb-15 2:26 
GeneralRe: Why is Array.Sort() slower if I use my own comparer? Pin
robinsc16-Feb-15 2:35
robinsc16-Feb-15 2:35 
SuggestionRe: Why is Array.Sort() slower if I use my own comparer? Pin
Richard Deeming16-Feb-15 8:20
mveRichard Deeming16-Feb-15 8:20 
GeneralRe: Why is Array.Sort() slower if I use my own comparer? Pin
Rob Philpott16-Feb-15 8:22
Rob Philpott16-Feb-15 8:22 
GeneralRe: Why is Array.Sort() slower if I use my own comparer? Pin
robinsc16-Feb-15 21:57
robinsc16-Feb-15 21:57 
AnswerRe: Why is Array.Sort() slower if I use my own comparer? Pin
Dave Kreskowiak16-Feb-15 2:56
mveDave Kreskowiak16-Feb-15 2:56 
GeneralRe: Why is Array.Sort() slower if I use my own comparer? Pin
robinsc16-Feb-15 3:23
robinsc16-Feb-15 3:23 
I tried as well to build a quicksort, taken and adapted to long from Searching and Sorting Algorithms via C#[^]

But it needs longer than Array.Sort... sorry, I forgot to update the stopwatch before. But now quicksort is still slower than the others.

private void compareSortsPerformance()
{
Stopwatch sw = new Stopwatch();
int Maximum = 10000000;
Random rand = new Random();
long[] la = new long[Maximum];
for (int i = 0; i < Maximum; i++)
la[i] = rand.Next();
sw.Start();
Array.Sort(la);
Console.WriteLine("Sort without icomparable" + sw.ElapsedMilliseconds);
for (int i = 0; i < Maximum; i++)
la[i] = rand.Next();
sortKeys sk = new sortKeys();
sw.Restart();
Array.Sort(la, sk);
Console.WriteLine("Sort with icomparable" + sw.ElapsedMilliseconds);

for (int i = 0; i < Maximum; i++)
la[i] = rand.Next();
sw.Restart();
QuickSort(ref la);
Console.WriteLine("Sort with Quicksort" + sw.ElapsedMilliseconds);

}

public static void QuickSort(ref long[] x)
{
qs(x, 0, x.Length - 1);
}

public static void qs(long[] x, long left, long right)
{
long i, j;
long pivot, temp;

i = left;
j = right;
pivot = x[(left + right) / 2];

do
{
while ((x[i] < pivot) && (i < right)) i++;
while ((pivot < x[j]) && (j > left)) j--;

if (i <= j)
{
temp = x[i];
x[i] = x[j];
x[j] = temp;
i++; j--;
}
} while (i <= j);

if (left < j) qs(x, left, j);
if (i < right) qs(x, i, right);
}
QuestionConsuming SAP Web Service in C# Pin
Amoxtli15-Feb-15 22:40
Amoxtli15-Feb-15 22:40 
GeneralRe: Consuming SAP Web Service in C# Pin
Richard MacCutchan15-Feb-15 23:05
mveRichard MacCutchan15-Feb-15 23:05 
GeneralRe: Consuming SAP Web Service in C# Pin
Amoxtli15-Feb-15 23:18
Amoxtli15-Feb-15 23:18 

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.