ModernUO/Projects/UOContent/Engines/ConPVP
Kamron Batman a4cabe2fa4
fix: Optimizes FindItemsByType by removing allocations. (#1515)
### Summary
Container enumeration is in dire need of optimization. Thanks to @stefanomerotta for initiating this work with PR #1443. This PR handles a small part of what Stefan started. Also included are some bug fixes.

### Method Signatures

```cs
// Use with foreach without moving/deleting items
FindItemsByTypeEnumerator<T> FindItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use with foreach when moving/deleting items
QueuedItemsEnumerator<T> EnumerateItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use when iterating multiple times or queuing
PooledRefQueue<T> QueueItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use when iterating multiples times or manipulating elements without traversing
PooledRefList<T> ListItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)
```

* `FindItemsByType<T>` has changed from returning `List<T>` to `FindItemsByTypeEnumerator<T>` - This method is not safe to use in situations where an item may get consumed, deleted, or moved.

* `EnumerateItemsByType<T>` was added as a safe way to iterate and manipulate items.
  * **Note**: EnumerateItemsByType will _completely traverse the container_ before iteration starts because it uses `QueueItemsByType` under the hood.

* `QueueItemsByType<T>`  and `ListItemsByType<T>` was added to return a queue or list of items to iterate multiple times and manipulate the items. This isn't the most efficient since it uses a predicate and can result in 2 or 3 total iterations unnecessarily.

### Bug Fixes
- [X] Fishing had an error in the random check that may have caused slight bias.
2023-09-28 19:36:45 -07:00
..
Games fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Gumps fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00
AcceptDuelGump.cs fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00
Arena.cs fix: Fixes region priority and resolution. (#1254) 2022-11-21 10:38:20 -08:00
DuelContext.cs fix: Codegens and fixes bugs with plant system (#1490) 2023-09-05 19:20:03 -07:00
DuelTeleporterAddon.cs Fixes brace style (#248) 2020-09-13 21:49:46 -07:00
Ladder.cs chore: Cleans up pattern checks. (#892) 2021-12-24 15:53:59 -08:00
Participant.cs fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
Preferences.cs fix: Fixes NPE crash from "i wish to duel" (#1410) 2023-06-05 22:50:15 +02:00
Ruleset.cs C# 9 Cleanup (#325) 2020-11-27 00:29:21 -08:00
RulesetLayout.cs C# 9 Cleanup (#325) 2020-11-27 00:29:21 -08:00
SafeZone.cs fix: Fixes region priority and resolution. (#1254) 2022-11-21 10:38:20 -08:00
Tournament.cs fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
TournamentBracketItem.cs fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
TournamentController.cs cleanup: Fixes bugs and cleans up code (#660) 2021-07-19 20:49:59 -07:00
TournamentPyramid.cs chore: Cleans up pattern checks. (#892) 2021-12-24 15:53:59 -08:00
TournamentRegistrar.cs fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
TournamentSignupItem.cs fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
TourneyParticipant.cs fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00
Trophy.cs fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283) 2022-11-28 19:58:12 -08:00