Tanoda
ReadonlyList.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using UnityEngine;
10using System.Collections.Generic;
11using System.Collections;
12
13namespace Leap.Unity {
14
20 public struct ReadonlyList<T> {
21 private readonly List<T> _list;
22
23 public ReadonlyList(List<T> list) {
24 _list = list;
25 }
26
27 public bool isValid {
28 get {
29 return _list != null;
30 }
31 }
32
33 public int Count {
34 get {
35 return _list.Count;
36 }
37 }
38
39 public T this[int index] {
40 get {
41 return _list[index];
42 }
43 }
44
45 public List<T>.Enumerator GetEnumerator() {
46 return _list.GetEnumerator();
47 }
48
49 public static implicit operator ReadonlyList<T>(List<T> list) {
50 return new ReadonlyList<T>(list);
51 }
52
53 public int IndexOf(T item) {
54 return _list.IndexOf(item);
55 }
56 }
57}
A simple wrapper around List to provide readonly access. Useful when you want to return a list to som...
Definition: ReadonlyList.cs:20
List< T >.Enumerator GetEnumerator()
Definition: ReadonlyList.cs:45
ReadonlyList(List< T > list)
Definition: ReadonlyList.cs:23