2010-05-06 19:20:38 +00:00
|
|
|
|
/*
|
|
|
|
|
|
2012-05-27 14:23:31 +00:00
|
|
|
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2010-05-06 19:20:38 +00:00
|
|
|
|
|
2013-06-09 16:08:59 +00:00
|
|
|
|
Copyright (C) 2009-2013 Michael Möller <mmoeller@openhardwaremonitor.org>
|
2012-05-27 14:23:31 +00:00
|
|
|
|
|
2010-05-06 19:20:38 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2010-05-09 16:22:13 +00:00
|
|
|
|
using System.Collections;
|
2010-05-06 19:20:38 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2010-08-08 13:57:26 +00:00
|
|
|
|
namespace OpenHardwareMonitor.Collections {
|
2010-08-15 14:46:58 +00:00
|
|
|
|
|
2010-05-09 16:22:13 +00:00
|
|
|
|
public class ListSet<T> : IEnumerable<T> {
|
2010-05-06 19:20:38 +00:00
|
|
|
|
|
2010-09-21 20:32:36 +00:00
|
|
|
|
private readonly List<T> list = new List<T>();
|
2010-05-06 19:20:38 +00:00
|
|
|
|
|
|
|
|
|
public bool Add(T item) {
|
|
|
|
|
if (list.Contains(item))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
list.Add(item);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Remove(T item) {
|
|
|
|
|
if (!list.Contains(item))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
list.Remove(item);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Contains(T item) {
|
|
|
|
|
return list.Contains(item);
|
|
|
|
|
}
|
2010-05-09 16:22:13 +00:00
|
|
|
|
|
|
|
|
|
public T[] ToArray() {
|
|
|
|
|
return list.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerator<T> GetEnumerator() {
|
|
|
|
|
return list.GetEnumerator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator() {
|
|
|
|
|
return list.GetEnumerator();
|
|
|
|
|
}
|
2013-06-09 16:08:59 +00:00
|
|
|
|
|
|
|
|
|
public int Count {
|
|
|
|
|
get {
|
|
|
|
|
return list.Count;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-06 19:20:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|