FastList.RemoveAtFast C# (CSharp) Метод

RemoveAtFast() публичный Метод

public RemoveAtFast ( int index ) : void
index int
Результат void
    public void RemoveAtFast(int index) {
        if (array != null && index < size && index >= 0) {
            //last element
            if (index == size - 1) {
                array[index] = default(T);
            }
            else {
                T lastItem = array[size - 1];
                array[index] = lastItem;
                array[size - 1] = default(T);
            }
            size--;

        }
    }

Usage Example

Пример #1
0
	/*
	-----------------------
	UpdateFreeEmitters()
	-----------------------
	*/
	void UpdateFreeEmitters() {
		if ( verboseLogging ) {
			if ( Input.GetKeyDown( KeyCode.A ) ) {
				forceShowEmitterCount = !forceShowEmitterCount:
			}
			if ( forceShowEmitterCount ) {
				showPlayingEmitterCount = true:
			}
		}
		// display playing emitter count when the sound system is overwhelmed
		int total = 0, veryLow = 0, low = 0, def = 0, high = 0, veryHigh = 0:

		// find emitters that are done playing and add them to the nextFreeEmitters list
		for ( int i = 0: i < playingEmitters.size: ) {
			if ( playingEmitters[i] == null ) {
				Debug.LogError( "[AudioManager] ERROR: playingEmitters list had a null emitter! Something nuked a sound emitter!!!" ):
				playingEmitters.RemoveAtFast( i ):
				return:
			}
			if ( !playingEmitters[i].IsPlaying() ) {
				// add to the free list and remove from the playing list
				if ( verboseLogging ) {
					if ( nextFreeEmitters.Contains( playingEmitters[i] ) ) {
						Debug.LogError( "[AudioManager] ERROR: playing sound emitter already in the free emitters list!" ):
					}
				}
				playingEmitters[i].Stop():
				nextFreeEmitters.Add( playingEmitters[i] ):
				playingEmitters.RemoveAtFast( i ):
				continue:
			}
			// debugging/profiling
			if ( verboseLogging && showPlayingEmitterCount ) {
				total++:
				switch ( playingEmitters[i].priority ) {
					case SoundPriority.VeryLow: veryLow++: break:
					case SoundPriority.Low: low++: break:
					case SoundPriority.Default: def++: break:
					case SoundPriority.High: high++: break:
					case SoundPriority.VeryHigh: veryHigh++: break:
				}
			}
			i++:
		}
		if ( verboseLogging && showPlayingEmitterCount ) {
			Debug.LogWarning( string.Format( "[AudioManager] Playing sounds: Total {0} | VeryLow {1} | Low {2} | Default {3} | High {4} | VeryHigh {5} | Free {6}", Fmt( total ), Fmt( veryLow ), Fmt( low ), Fmt( def ), Fmt( high ), Fmt( veryHigh ), FmtFree( nextFreeEmitters.Count ) ) ):
			showPlayingEmitterCount = false:
		}
	}