예제 #1
0
 public void ValidateExistingHandle(StaticHandle handle)
 {
     Debug.Assert(StaticExists(handle), "Handle must exist according to the StaticExists test.");
     Debug.Assert(handle.Value >= 0, "Handles must be nonnegative.");
     Debug.Assert(handle.Value < HandleToIndex.Length && HandleToIndex[handle.Value] >= 0 && IndexToHandle[HandleToIndex[handle.Value]].Value == handle.Value,
                  "This static handle doesn't seem to exist, or the mappings are out of sync. If a handle exists, both directions should match.");
 }
예제 #2
0
 /// <summary>
 /// Gets a reference to the properties associated with a static's handle.
 /// </summary>
 /// <param name="staticHandle">Static handle to retrieve the properties for.</param>
 /// <returns>Reference to properties associated with a static handle.</returns>
 public ref T this[StaticHandle staticHandle]
 {
     [MethodImpl(MethodImplOptions.AggressiveInlining)]
     get
     {
         Debug.Assert(simulation.Statics.StaticExists(staticHandle));
         return(ref staticData[staticHandle.Value]);
     }
 }
예제 #3
0
 public bool StaticExists(StaticHandle handle)
 {
     if (handle.Value < 0 || handle.Value >= HandleToIndex.Length)
     {
         return(false);
     }
     //A negative index marks a static handle as unused.
     return(HandleToIndex[handle.Value] >= 0);
 }
예제 #4
0
 public ref T Allocate(StaticHandle handle)
 {
     Debug.Assert(simulation.Statics.StaticExists(handle), "The static handle should have been allocated in the statics set before any attempt to create a property for it.");
     if (handle.Value >= staticData.Length)
     {
         var targetCount = BufferPool.GetCapacityForCount <T>(simulation.Statics.HandlePool.HighestPossiblyClaimedId + 1);
         Debug.Assert(targetCount > staticData.Length, "Given what just happened, we must require a resize.");
         pool.ResizeToAtLeast(ref staticData, targetCount, Math.Min(simulation.Statics.HandlePool.HighestPossiblyClaimedId + 1, staticData.Length));
     }
     return(ref staticData[handle.Value]);
 }
예제 #5
0
 /// <summary>
 /// Constructs a new static reference.
 /// </summary>
 /// <param name="handle">Handle of the static to refer to.</param>
 /// <param name="statics">Collection containing the static.</param>
 public StaticReference(StaticHandle handle, Statics statics)
 {
     Handle  = handle;
     Statics = statics;
 }