mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 20:22:55 +08:00
History -> LimitedCapacityStack + re-xmldoc
This commit is contained in:
parent
af0bb4d5e8
commit
3784b673ae
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Difficulty.Skills
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="DifficultyHitObject"/>s that were processed previously. They can affect the strain values of the following objects.
|
/// <see cref="DifficultyHitObject"/>s that were processed previously. They can affect the strain values of the following objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly History<DifficultyHitObject> Previous = new History<DifficultyHitObject>(2); // Contained objects not used yet
|
protected readonly LimitedCapacityStack<DifficultyHitObject> Previous = new LimitedCapacityStack<DifficultyHitObject>(2); // Contained objects not used yet
|
||||||
|
|
||||||
private double currentStrain = 1; // We keep track of the strain level at all times throughout the beatmap.
|
private double currentStrain = 1; // We keep track of the strain level at all times throughout the beatmap.
|
||||||
private double currentSectionPeak = 1; // We also keep track of the peak strain level in the current section.
|
private double currentSectionPeak = 1; // We also keep track of the peak strain level in the current section.
|
||||||
|
@ -8,11 +8,13 @@ using System.Collections.Generic;
|
|||||||
namespace osu.Game.Rulesets.Difficulty.Utils
|
namespace osu.Game.Rulesets.Difficulty.Utils
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An indexed stack with Push() only, which disposes items at the bottom after the capacity is full.
|
/// An indexed stack with limited depth. Indexing starts at the top of the stack.
|
||||||
/// Indexing starts at the top of the stack.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class History<T> : IEnumerable<T>
|
public class LimitedCapacityStack<T> : IEnumerable<T>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The number of elements in the stack.
|
||||||
|
/// </summary>
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
private readonly T[] array;
|
private readonly T[] array;
|
||||||
@ -20,10 +22,10 @@ namespace osu.Game.Rulesets.Difficulty.Utils
|
|||||||
private int marker; // Marks the position of the most recently added item.
|
private int marker; // Marks the position of the most recently added item.
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the History class that is empty and has the specified capacity.
|
/// Constructs a new <see cref="LimitedCapacityStack{T}"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="capacity">The number of items the History can hold.</param>
|
/// <param name="capacity">The number of items the stack can hold.</param>
|
||||||
public History(int capacity)
|
public LimitedCapacityStack(int capacity)
|
||||||
{
|
{
|
||||||
if (capacity < 0)
|
if (capacity < 0)
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
@ -34,8 +36,9 @@ namespace osu.Game.Rulesets.Difficulty.Utils
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The most recently added item is returned at index 0.
|
/// Retrieves the item at an index in the stack.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="i">The index of the item to retrieve. The top of the stack is returned at index 0.</param>
|
||||||
public T this[int i]
|
public T this[int i]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -52,11 +55,12 @@ namespace osu.Game.Rulesets.Difficulty.Utils
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds the item as the most recent one in the history.
|
/// Pushes an item to this <see cref="LimitedCapacityStack{T}"/>.
|
||||||
/// The oldest item is disposed if the history is full.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Push(T item) // Overwrite the oldest item instead of shifting every item by one with every addition.
|
/// <param name="item">The item to push.</param>
|
||||||
|
public void Push(T item)
|
||||||
{
|
{
|
||||||
|
// Overwrite the oldest item instead of shifting every item by one with every addition.
|
||||||
if (marker == 0)
|
if (marker == 0)
|
||||||
marker = capacity - 1;
|
marker = capacity - 1;
|
||||||
else
|
else
|
Loading…
Reference in New Issue
Block a user