Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Simple Particle Engine for a shooter game
Snake / Nibbles clone in C and Ncurses
Please improve
Parsing of XML data has high CPU usage
Convert simple Javascript to jQuery plugin
Active Record getting unique records
List the files in a directory without the directory name or the extension
clean the code
ohs system, recruitment software, hr software, oh&s software, human resources software, ohs software
Array parsing in a block
Popular
Parsing of XML data has high CPU usage
Please improve
Snake / Nibbles clone in C and Ncurses
List the files in a directory without the directory name or the extension
Convert simple Javascript to jQuery plugin
Simple Particle Engine for a shooter game
Active Record getting unique records
Breadth first cartesian product iterator
php refactoring
first BST
Pastable version of
IEnumerable<> comparision extension method
<pre class='prettyprint' language='cs'>/// <summary> /// Compares the content of two enumerables for equality. Order /// of elements does NOT matter. Elements may exist multiple /// times. <c>null</c> is both a valid key and value. /// /// O(n). Fast for elements with well distributed hashcode. /// </summary> public static bool ContentEquals<T> ( this IEnumerable<T> first, IEnumerable<T> second, IEqualityComparer<T> comparer) { // Declare a dictionary to count the occurence of the items in the collection Dictionary<T, int> itemCounts = new Dictionary<T, int> (comparer); // null references are stored here. int zero = 0; // Increase the count for each occurence of the item in the first collection foreach (T item in first) { if (item == null) { zero++; } else if (itemCounts.ContainsKey (item)) { itemCounts[item]++; } else { itemCounts[item] = 1; } } // Decrease the count for each occurence of the item in the second collection foreach (T item in second) { if (item == null) { zero--; } else if (itemCounts.ContainsKey (item)) { itemCounts[item]--; } else { // There was no occurence of this item in the first collection, thus the collections are not equal return false; } } // The count of each item should be 0 if the contents of the collections are equal foreach (int value in itemCounts.Values) { if (value != 0) { return false; } } if (zero != 0) { return false; } // The collections are equal return true; }</pre> <a href="http://www.refactormycode.com/codes/928-ienumerable-comparision-extension-method" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>