-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
83 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Arands.Content | ||
{ | ||
public static class Extensions | ||
{ | ||
/// <summary> | ||
/// Removes all elements from the List that match the conditions defined by the specified predicate. | ||
/// </summary> | ||
/// <typeparam name="T">The type of elements held by the List.</typeparam> | ||
/// <param name="list">The List to remove the elements from.</param> | ||
/// <param name="match">The Predicate delegate that defines the conditions of the elements to remove.</param> | ||
public static int RemoveAll<T>(this System.Collections.Generic.List<T> list, Func<T, bool> match) | ||
{ | ||
int numberRemoved = 0; | ||
|
||
// Loop through every element in the List, in reverse order since we are removing items. | ||
for (int i = (list.Count - 1); i >= 0; i--) | ||
{ | ||
// If the predicate function returns true for this item, remove it from the List. | ||
if (match(list[i])) | ||
{ | ||
list.RemoveAt(i); | ||
numberRemoved++; | ||
} | ||
} | ||
|
||
// Return how many items were removed from the List. | ||
return numberRemoved; | ||
} | ||
|
||
/// <summary> | ||
/// Returns true if the List contains elements that match the conditions defined by the specified predicate. | ||
/// </summary> | ||
/// <typeparam name="T">The type of elements held by the List.</typeparam> | ||
/// <param name="list">The List to search for a match in.</param> | ||
/// <param name="match">The Predicate delegate that defines the conditions of the elements to match against.</param> | ||
public static bool Exists<T>(this System.Collections.Generic.List<T> list, Func<T, bool> match) | ||
{ | ||
// Loop through every element in the List, until a match is found. | ||
for (int i = 0; i < list.Count; i++) | ||
{ | ||
// If the predicate function returns true for this item, return that at least one match was found. | ||
if (match(list[i])) | ||
return true; | ||
} | ||
|
||
// Return that no matching elements were found in the List. | ||
return false; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 16 additions & 9 deletions
25
ContentTrackerTestGame/ContentTrackerTestGame.Xbox.csproj.Debug.cachefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
Content\SpriteFont1.xnb | ||
Content\Pyramid.xnb | ||
Content\TerrainDarkStone2.xnb | ||
Content\Teapot.xnb | ||
Content\Torus.xnb | ||
Content\Cone.xnb | ||
Content\Cylinder.xnb | ||
Content\Pyramid.xnb | ||
Content\SkyDay.xnb | ||
Content\Teapot.xnb | ||
Content\TerrainDarkStone2.xnb | ||
Content\Torus.xnb | ||
Content\SpriteFont1.xnb | ||
Content\jungle.xnb | ||
Content\moss.xnb | ||
Content\Sanddune.xnb | ||
Content\SkyDayTexture.xnb | ||
Content\stone.xnb | ||
Content\TerrainDesertCanyon.xnb | ||
Content\wood_worn.xnb | ||
Content\moss_0.xnb | ||
Content\TerrainDesertCanyon_0.xnb | ||
Content\jungle_0.xnb | ||
Content\stone_0.xnb | ||
Content\SkyDayTexture_0.xnb | ||
Content\Sanddune_0.xnb | ||
Content\stone_0.xnb | ||
Content\wood_worn_0.xnb | ||
Content\moss_0.xnb | ||
Content\TerrainDesertCanyon_0.xnb | ||
Content\SkyDay_0.xnb |
Binary file not shown.