Here are the examples of the csharp api System.Collections.Generic.List.Add(T) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2808 Examples
19
Source : SqliteUserData.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public override T[] LoadAll<T>() {
using UserDataBatchContext batch = OpenBatch();
string table = GetDataTable(typeof(T), false);
if (table.IsNullOrEmpty())
return Dummy<T>.EmptyArray;
using MiniCommand mini = new(this) {
SqliteOpenMode.ReadOnly,
@$"
SELECT format, value
FROM [{table}];
",
};
(SqliteConnection con, SqliteCommand cmd, SqliteDataReader reader) = mini.Read();
List<T> values = new();
while (reader.Read()) {
switch ((DataFormat) reader.GetInt32(0)) {
case DataFormat.MessagePack:
default: {
using Stream stream = reader.GetStream(1);
values.Add(MessagePackSerializer.Deserialize<T>(stream, MessagePackHelper.Options) ?? new());
break;
}
case DataFormat.Yaml: {
using Stream stream = reader.GetStream(1);
using StreamReader streamReader = new(stream);
values.Add(YamlHelper.Deserializer.Deserialize<T>(streamReader) ?? new());
break;
}
}
}
return values.ToArray();
}
19
Source : SqliteUserData.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public override T[] LoadRegistered<T>() {
using UserDataBatchContext batch = OpenBatch();
string table = GetDataTable(typeof(T), false);
if (table.IsNullOrEmpty())
return Dummy<T>.EmptyArray;
using MiniCommand mini = new(this) {
SqliteOpenMode.ReadOnly,
@$"
SELECT D.format, D.value
FROM [{table}] D
INNER JOIN meta M ON D.uid = M.uid
WHERE M.registered = 1;
",
};
(SqliteConnection con, SqliteCommand cmd, SqliteDataReader reader) = mini.Read();
List<T> values = new();
while (reader.Read()) {
switch ((DataFormat) reader.GetInt32(0)) {
case DataFormat.MessagePack:
default: {
using Stream stream = reader.GetStream(1);
values.Add(MessagePackSerializer.Deserialize<T>(stream, MessagePackHelper.Options) ?? new());
break;
}
case DataFormat.Yaml: {
using Stream stream = reader.GetStream(1);
using StreamReader streamReader = new(stream);
values.Add(YamlHelper.Deserializer.Deserialize<T>(streamReader) ?? new());
break;
}
}
}
return values.ToArray();
}
19
Source : _.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public static List<T> GetList<T>(int count, Func<int, T> get) {
if (count <= 0)
return new List<T>();
List<T> list = new List<T>(count);
for (int i = 0; i < count; i++)
list.Add(get(i));
return list;
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitPlainProperty(string name, IReadOnlyList<byte>? value, int ctx)
{
this._buffer.Add(this._factory(ctx, ctx, null, false, name, value != null ? Convert.ToBase64String(value.ToArray()) : null));
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public VisitorResult<int> VisitExpr(IExpr expr, string typeTag, int ctx)
{
var newId = this._currentId;
this._buffer.Add(this._factory(newId, ctx, null, true, typeTag, null));
return VisitorResult<int>.Continue(newId);
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitProperty(string name, bool isArray, bool isNull, int ctx)
{
if (!isNull && !isArray)
{
this._buffer.Add(this._factory(this.GetNewId(), ctx, null, false, name, null));
}
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitArrayItem(string name, int arrayIndex, int ctx)
{
this._buffer.Add(this._factory(this.GetNewId(), ctx, arrayIndex, false, name, null));
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitPlainProperty(string name, string? value, int ctx)
{
this._buffer.Add(this._factory(ctx, ctx, null, false, name, value));
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitPlainProperty(string name, bool? value, int ctx)
{
this._buffer.Add(this._factory(ctx, ctx, null, false, name, value?.ToString(CultureInfo.InvariantCulture)));
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitPlainProperty(string name, byte? value, int ctx)
{
this._buffer.Add(this._factory(ctx, ctx, null, false, name, value?.ToString(CultureInfo.InvariantCulture)));
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitPlainProperty(string name, short? value, int ctx)
{
this._buffer.Add(this._factory(ctx, ctx, null, false, name, value?.ToString(CultureInfo.InvariantCulture)));
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitPlainProperty(string name, int? value, int ctx)
{
this._buffer.Add(this._factory(ctx, ctx, null, false, name, value?.ToString(CultureInfo.InvariantCulture)));
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitPlainProperty(string name, long? value, int ctx)
{
this._buffer.Add(this._factory(ctx, ctx, null, false, name, value?.ToString(CultureInfo.InvariantCulture)));
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitPlainProperty(string name, decimal? value, int ctx)
{
this._buffer.Add(this._factory(ctx, ctx, null, false, name, value?.ToString(CultureInfo.InvariantCulture)));
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitPlainProperty(string name, double? value, int ctx)
{
this._buffer.Add(this._factory(ctx, ctx, null, false, name, value?.ToString(CultureInfo.InvariantCulture)));
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitPlainProperty(string name, DateTime? value, int ctx)
{
if (value != null)
{
string ts = value.Value.ToString("yyyy-MM-ddTHH:mm:ss.fff");
this._buffer.Add(this._factory(ctx, ctx, null, false, name, ts));
}
}
19
Source : ExprPlainWriter.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public void VisitPlainProperty(string name, Guid? value, int ctx)
{
this._buffer.Add(this._factory(ctx, ctx, null, false, name, value?.ToString("D")));
}
19
Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios
with GNU General Public License v3.0
from 1330-Studios
public static Il2CppReferenceArray<T> Remove<T>(this Il2CppReferenceArray<T> reference, Func<T, bool> predicate) where T : Model {
List<T> bases = new List<T>();
foreach (var tmp in reference)
if (!predicate(tmp))
bases.Add(tmp);
return new(bases.ToArray());
}
19
Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios
with GNU General Public License v3.0
from 1330-Studios
public static Il2CppReferenceArray<T> Add<T>(this Il2CppReferenceArray<T> reference, params T[] newPart) where T : Model {
var bases = new List<T>();
foreach (var tmp in reference)
bases.Add(tmp);
foreach (var tmp in newPart)
bases.Add(tmp);
return new(bases.ToArray());
}
19
Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios
with GNU General Public License v3.0
from 1330-Studios
public static Il2CppReferenceArray<T> Add<T>(this Il2CppReferenceArray<T> reference, params T[] newPart) where T : Model {
var bases = new List<T>();
foreach (var tmp in reference)
bases.Add(tmp);
foreach (var tmp in newPart)
bases.Add(tmp);
return new(bases.ToArray());
}
19
Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios
with GNU General Public License v3.0
from 1330-Studios
public static Il2CppReferenceArray<T> Add<T>(this Il2CppReferenceArray<T> reference, IEnumerable<T> enumerable) where T : Model {
var bases = new List<T>();
foreach (var tmp in reference)
bases.Add(tmp);
var enumerator = enumerable.GetEnumerator();
while (enumerator.MoveNext()) bases.Add(enumerator.Current);
return new(bases.ToArray());
}
19
Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios
with GNU General Public License v3.0
from 1330-Studios
public static Il2CppReferenceArray<T> Add<T>(this Il2CppReferenceArray<T> reference, IEnumerable<T> enumerable) where T : Model {
var bases = new List<T>();
foreach (var tmp in reference)
bases.Add(tmp);
var enumerator = enumerable.GetEnumerator();
while (enumerator.MoveNext()) bases.Add(enumerator.Current);
return new(bases.ToArray());
}
19
Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios
with GNU General Public License v3.0
from 1330-Studios
public static Il2CppReferenceArray<T> Add<T>(this Il2CppReferenceArray<T> reference, params T[] newPart) where T : Il2CppObjectBase {
var bases = new List<T>();
foreach (var tmp in reference)
bases.Add(tmp);
foreach (var tmp in newPart)
bases.Add(tmp);
return new(bases.ToArray());
}
19
Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios
with GNU General Public License v3.0
from 1330-Studios
public static Il2CppReferenceArray<T> Add<T>(this Il2CppReferenceArray<T> reference, params T[] newPart) where T : Il2CppObjectBase {
var bases = new List<T>();
foreach (var tmp in reference)
bases.Add(tmp);
foreach (var tmp in newPart)
bases.Add(tmp);
return new(bases.ToArray());
}
19
Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios
with GNU General Public License v3.0
from 1330-Studios
public static T[] Reversed<T>(this T[] reference) {
var bases = new List<T>();
for (int i = reference.Length - 1; i >= 0; i--)
bases.Add(reference[i]);
return bases.ToArray();
}
19
Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios
with GNU General Public License v3.0
from 1330-Studios
public static Il2CppReferenceArray<T> Remove<T>(this Il2CppReferenceArray<T> reference, Func<T, bool> predicate) where T : Il2CppObjectBase {
List<T> bases = new List<T>();
foreach (var tmp in reference)
if (!predicate(tmp))
bases.Add(tmp);
return new(bases.ToArray());
}
19
Source : DbContext.cs
with Apache License 2.0
from 1448376744
with Apache License 2.0
from 1448376744
public IEnumerable<T> Query<T>(string sql, object parameter = null, int? commandTimeout = null, CommandType? commandType = null)
{
using (var cmd = Connection.CreateCommand())
{
var list = new List<T>();
Initialize(cmd, sql, parameter, commandTimeout, commandType);
using (var reader = cmd.ExecuteReader())
{
var handler = GlobalSettings.EnreplacedyMapperProvider.GetSerializer<T>(reader);
while (reader.Read())
{
list.Add(handler(reader));
}
return list;
}
}
}
19
Source : DbContext.cs
with Apache License 2.0
from 1448376744
with Apache License 2.0
from 1448376744
public async Task<IEnumerable<T>> QueryAsync<T>(string sql, object parameter = null, int? commandTimeout = null, CommandType? commandType = null)
{
using (var cmd = (Connection as DbConnection).CreateCommand())
{
Initialize(cmd, sql, parameter, commandTimeout, commandType);
using (var reader = await cmd.ExecuteReaderAsync())
{
var list = new List<T>();
var handler = GlobalSettings.EnreplacedyMapperProvider.GetSerializer<T>(reader);
while (await reader.ReadAsync())
{
list.Add(handler(reader));
}
return list;
}
}
}
19
Source : DbMultipleResult.cs
with Apache License 2.0
from 1448376744
with Apache License 2.0
from 1448376744
public List<T> GetList<T>()
{
var handler = GlobalSettings.EnreplacedyMapperProvider.GetSerializer<T>(_reader);
var list = new List<T>();
while (_reader.Read())
{
list.Add(handler(_reader));
}
NextResult();
return list;
}
19
Source : DbMultipleResult.cs
with Apache License 2.0
from 1448376744
with Apache License 2.0
from 1448376744
public async Task<List<T>> GetListAsync<T>()
{
var handler = GlobalSettings.EnreplacedyMapperProvider.GetSerializer<T>(_reader);
var list = new List<T>();
while (await (_reader as DbDataReader).ReadAsync())
{
list.Add(handler(_reader));
}
NextResult();
return list;
}
19
Source : ICollectionResolverTest_CustomTypeImpl.cs
with MIT License
from 1996v
with MIT License
from 1996v
public void Add(T item)
{
_ary.Add(item);
}
19
Source : XmlHelper.cs
with MIT License
from 279328316
with MIT License
from 279328316
public IEnumerable<T> DeserializeNodeCollection<T>(XmlNode node = null) where T : clreplaced, new()
{
List<T> result = new List<T>();
XmlNode firstChild;
if (node == null)
{
node = root;
}
firstChild = node.FirstChild;
while (firstChild != null)
{
result.Add(DeserializeNode<T>(firstChild));
firstChild = firstChild.NextSibling;
}
return result;
}
19
Source : InternalExtensions.cs
with MIT License
from 2881099
with MIT License
from 2881099
public static List<T> MapToList<T>(this object[] list, Func<object, object, T> selector)
{
if (list == null) return null;
if (list.Length % 2 != 0) throw new ArgumentException($"Array {nameof(list)} length is not even");
var ret = new List<T>();
for (var a = 0; a < list.Length; a += 2)
{
var selval = selector(list[a], list[a + 1]);
if (selval != null) ret.Add(selval);
}
return ret;
}
19
Source : SynchSubscribers.cs
with MIT License
from 3F
with MIT License
from 3F
public bool Register(T listener)
{
lock(sync)
{
if(Contains(listener)) {
return false;
}
//items.Insert(Count, listener);
listeners.Add(listener);
accessor[listener.Id] = listener;
LSender.Send(this, $"listener has been added into container - {listener.Id}", Message.Level.Debug);
return true;
}
}
19
Source : ItemManager.cs
with MIT License
from 404Lcc
with MIT License
from 404Lcc
public T[] Gereplacedems<T>(ItemType type) where T : AObjectBase
{
if (ItemExist(type))
{
Item[] items = (Item[])this.items[type];
List<T> aObjectBaseList = new List<T>();
foreach (Item item in items)
{
aObjectBaseList.Add((T)item.AObjectBase);
}
return aObjectBaseList.ToArray();
}
return null;
}
19
Source : Helper.cs
with MIT License
from 5minlab
with MIT License
from 5minlab
internal static List<T> Convert<T>(List<object> l) {
var retval = new List<T>();
foreach(var el in l) {
if(el == null) { continue; }
if(typeof(T).IsreplacedignableFrom(el.GetType())) {
retval.Add((T)el);
}
}
return retval;
}
19
Source : StringExtension.cs
with GNU Lesser General Public License v3.0
from 8720826
with GNU Lesser General Public License v3.0
from 8720826
public static List<T> StrToList<T>(this string str, char separator = ',')
{
var list = new List<T>();
if (string.IsNullOrEmpty(str))
{
return list;
}
foreach (var c in str.Split(separator))
{
if (c.Length == 0) { continue; }
try
{
T result = (T)Convert.ChangeType(c, typeof(T));
if (result == null) { continue; }
list.Add(result);
}
catch (Exception)
{
}
}
return list;
}
19
Source : DelayedQueue.cs
with GNU Lesser General Public License v3.0
from 8720826
with GNU Lesser General Public License v3.0
from 8720826
public async Task<List<T>> Subscribe<T>()
{
var channel = typeof(T).Name.ToLower();
var list = new List<T>();
var timestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
var playerIds = await _redisDb.SortedSetRangeByScore($"{queueName}_{channel}", timestamp);
if (playerIds == null || playerIds.Count == 0)
{
return default;
}
foreach (var playerId in playerIds)
{
var t = await _redisDb.StringGet<T>($"{queueName}_{channel}_{playerId}");
list.Add(t);
await _redisDb.SortedSetRemove($"{queueName}_{channel}", playerId);
await _redisDb.KeyDelete($"{queueName}_{channel}_{playerId}");
}
return list;
}
19
Source : Amf3Writer.cs
with MIT License
from a1q123456
with MIT License
from a1q123456
private void WriteStringBytesImpl<T>(string value, SerializationContext context, List<T> referenceTable)
{
if (value is T tValue)
{
var refIndex = referenceTable.IndexOf(tValue);
if (refIndex >= 0)
{
var header = (uint)refIndex << 1;
WriteU29BytesImpl(header, context);
return;
}
else
{
var byteCount = (uint)Encoding.UTF8.GetByteCount(value);
var header = (byteCount << 1) | 0x01;
WriteU29BytesImpl(header, context);
var backend = _arrayPool.Rent((int)byteCount);
try
{
Encoding.UTF8.GetBytes(value, backend);
context.Buffer.WriteToBuffer(backend.replacedpan(0, (int)byteCount));
}
finally
{
_arrayPool.Return(backend);
}
if (value.Any())
{
referenceTable.Add(tValue);
}
}
}
else
{
Contract.replacedert(false);
}
}
19
Source : Vector.cs
with MIT License
from a1q123456
with MIT License
from a1q123456
public new void Add(T item)
{
if (IsFixedSize)
{
throw new NotSupportedException();
}
((List<T>)this).Add(item);
}
19
Source : Amf3Reader.cs
with MIT License
from a1q123456
with MIT License
from a1q123456
private bool TryGetStringImpl<T>(Span<byte> objectBuffer, List<T> referenceTable, out string value, out int consumed) where T : clreplaced
{
value = default;
consumed = default;
if (!TryGetU29Impl(objectBuffer, out var header, out int headerLen))
{
return false;
}
if (!TryGetReference(header, _stringReferenceTable, out var headerData, out string refValue, out var isRef))
{
return false;
}
if (isRef)
{
value = refValue;
consumed = headerLen;
return true;
}
var strLen = (int)headerData;
if (objectBuffer.Length - headerLen < strLen)
{
return false;
}
value = Encoding.UTF8.GetString(objectBuffer.Slice(headerLen, strLen));
consumed = headerLen + strLen;
if (value.Any())
{
referenceTable.Add(value as T);
}
return true;
}
19
Source : ListExtension.cs
with MIT License
from a3geek
with MIT License
from a3geek
public static void SetCount<T>(this List<T> list, int count, Func<int, T> defaultValue = null)
{
count = count < 0 ? 0 : count;
defaultValue = defaultValue ?? (i => default(T));
if(list.Count < count)
{
for(var i = list.Count; i < count; i++)
{
list.Add(defaultValue(i));
}
}
else if(list.Count > count)
{
list.RemoveRange(count, list.Count - count);
}
}
19
Source : UMAAssetIndexer.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public List<T> GetAllreplacedets<T>(string[] foldersToSearch = null) where T : UnityEngine.Object
{
var st = StartTimer();
var ret = new List<T>();
System.Type ot = typeof(T);
System.Type theType = TypeToLookup[ot];
Dictionary<string, replacedereplacedem> TypeDic = GetreplacedetDictionary(theType);
foreach (KeyValuePair<string, replacedereplacedem> kp in TypeDic)
{
if (replacedetFolderCheck(kp.Value, foldersToSearch))
ret.Add((kp.Value.Item as T));
}
StopTimer(st, "GetAllreplacedets type=" + typeof(T).Name);
return ret;
}
19
Source : RandomWeaponGeneratorWindow.cs
with MIT License
from Abdelfattah-Radwan
with MIT License
from Abdelfattah-Radwan
private void DrawList<T>(ref List<T> list) where T : Object
{
Event currentEvent = Event.current;
Rect dropRect = GUILayoutUtility.GetRect(0.0f, 32.0f, GUILayout.ExpandWidth(true));
GUI.Box(dropRect, "Drag and drop items here to add to the list", EditorStyles.helpBox);
if (currentEvent.type == EventType.DragUpdated || currentEvent.type == EventType.DragPerform)
{
if (dropRect.Contains(currentEvent.mousePosition))
{
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
if (currentEvent.type == EventType.DragPerform)
{
foreach (Object objectReference in DragAndDrop.objectReferences)
{
if (objectReference is T typeReference)
{
if (list == null)
{
list = new List<T>();
}
list.Add(typeReference);
}
}
DragAndDrop.AcceptDrag();
currentEvent.Use();
}
}
}
if (GUILayout.Button("Add"))
{
if (list == null)
{
list = new List<T>();
}
list.Add(null);
}
if (list != null && list.Count != 0)
{
for (int i = 0; i < list.Count; i++)
{
EditorGUILayout.BeginHorizontal();
list[i] = EditorGUILayout.ObjectField(list[i], typeof(T), false) as T;
if (GUILayout.Button("-", GUILayout.MaxWidth(32f)))
{
list.RemoveAt(i);
}
EditorGUILayout.EndHorizontal();
}
}
else
{
EditorGUILayout.LabelField("Empty...", EditorStyles.centeredGreyMiniLabel);
}
}
19
Source : RandomWeaponGeneratorWindow.cs
with MIT License
from Abdelfattah-Radwan
with MIT License
from Abdelfattah-Radwan
private void DrawList<T>(ref List<T> list) where T : Object
{
Event currentEvent = Event.current;
Rect dropRect = GUILayoutUtility.GetRect(0.0f, 32.0f, GUILayout.ExpandWidth(true));
GUI.Box(dropRect, "Drag and drop items here to add to the list", EditorStyles.helpBox);
if (currentEvent.type == EventType.DragUpdated || currentEvent.type == EventType.DragPerform)
{
if (dropRect.Contains(currentEvent.mousePosition))
{
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
if (currentEvent.type == EventType.DragPerform)
{
foreach (Object objectReference in DragAndDrop.objectReferences)
{
if (objectReference is T typeReference)
{
if (list == null)
{
list = new List<T>();
}
list.Add(typeReference);
}
}
DragAndDrop.AcceptDrag();
currentEvent.Use();
}
}
}
if (GUILayout.Button("Add"))
{
if (list == null)
{
list = new List<T>();
}
list.Add(null);
}
if (list != null && list.Count != 0)
{
for (int i = 0; i < list.Count; i++)
{
EditorGUILayout.BeginHorizontal();
list[i] = EditorGUILayout.ObjectField(list[i], typeof(T), false) as T;
if (GUILayout.Button("-", GUILayout.MaxWidth(32f)))
{
list.RemoveAt(i);
}
EditorGUILayout.EndHorizontal();
}
}
else
{
EditorGUILayout.LabelField("Empty...", EditorStyles.centeredGreyMiniLabel);
}
}
19
Source : TextSegmentCollection.cs
with MIT License
from Abdesol
with MIT License
from Abdesol
void FindOverlappingSegments(List<T> results, TextSegment node, int low, int high)
{
// low and high are relative to node.LeftMost startpos (not node.LeftMost.Offset)
if (high < 0) {
// node is irrelevant for search because all intervals in node are after high
return;
}
// find values relative to node.Offset
int nodeLow = low - node.nodeLength;
int nodeHigh = high - node.nodeLength;
if (node.left != null) {
nodeLow -= node.left.totalNodeLength;
nodeHigh -= node.left.totalNodeLength;
}
if (node.distanceToMaxEnd < nodeLow) {
// node is irrelevant for search because all intervals in node are before low
return;
}
if (node.left != null)
FindOverlappingSegments(results, node.left, low, high);
if (nodeHigh < 0) {
// node and everything in node.right is before low
return;
}
if (nodeLow <= node.segmentLength) {
results.Add((T)node);
}
if (node.right != null)
FindOverlappingSegments(results, node.right, nodeLow, nodeHigh);
}
19
Source : BaseDataProviderAccessCoreSystem.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public virtual IReadOnlyList<T> GetDataProviders<T>() where T : IMixedRealityDataProvider
{
List<T> selected = new List<T>();
foreach (var provider in dataProviders)
{
if (provider is T)
{
selected.Add((T)provider);
}
}
return selected;
}
19
Source : BaseServiceManager.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public IReadOnlyList<T> GetServices<T>(string name = null) where T : IMixedRealityService
{
Type interfaceType = typeof(T);
List<T> matchingServices = new List<T>();
foreach(IMixedRealityService service in registeredServices.Values)
{
if (!interfaceType.IsreplacedignableFrom(service.GetType())) { continue; }
// If a name has been provided and if it matches the services's name, add the service.
if (!string.IsNullOrWhiteSpace(name) && string.Equals(service.Name, name))
{
matchingServices.Add((T)service);
}
// If no name has been specified, always add the service.
else
{
matchingServices.Add((T)service);
}
}
return matchingServices;
}
19
Source : DeserializeableList.cs
with MIT License
from absurd-joy
with MIT License
from absurd-joy
public void Add(T item) {_Data.Add(item);}
19
Source : PriortyQueue.cs
with Apache License 2.0
from acarteas
with Apache License 2.0
from acarteas
public void Enqueue(T item)
{
//calculate positions
int current_position = _items.Count;
int parent_position = (current_position - 1) / 2;
//insert element (note: may get erased if we hit the WHILE loop)
_items.Add(item);
//find parent, but be careful if we are an empty queue
T parent = default(T);
if (parent_position >= 0)
{
//find parent
parent = _items[parent_position];
//bubble up until we're done
while (_comparer.Compare(parent, item) > 0 && current_position > 0)
{
//move parent down
_items[current_position] = parent;
//recalculate position
current_position = parent_position;
parent_position = (current_position - 1) / 2;
//make sure that we have a valid index
if (parent_position >= 0)
{
//find parent
parent = _items[parent_position];
}
}
} //end check for nullptr
//after WHILE loop, current_position will point to the place that
//variable "item" needs to go
_items[current_position] = item;
}
See More Examples