2010-12-04 16:14:34 +00:00
|
|
|
|
/********************************************************
|
|
|
|
|
* Interfaces.h *
|
|
|
|
|
* *
|
|
|
|
|
* XFX Generic Interfaces definition file *
|
|
|
|
|
* Copyright <EFBFBD> XFX Team. All Rights Reserved *
|
|
|
|
|
********************************************************/
|
|
|
|
|
#ifndef _SYSTEM_COLLECTIONS_GENERIC_INTERFACES_
|
|
|
|
|
#define _SYSTEM_COLLECTIONS_GENERIC_INTERFACES_
|
|
|
|
|
|
|
|
|
|
#include <System/Types.h>
|
|
|
|
|
|
|
|
|
|
namespace System
|
|
|
|
|
{
|
|
|
|
|
namespace Collections
|
|
|
|
|
{
|
|
|
|
|
namespace Generic
|
|
|
|
|
{
|
2011-11-07 01:29:50 +00:00
|
|
|
|
// Defines methods to manipulate generic collections.
|
2010-12-04 16:14:34 +00:00
|
|
|
|
template <class T>
|
|
|
|
|
interface ICollection
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-11-07 01:29:50 +00:00
|
|
|
|
virtual void Add(T item)=0;
|
2010-12-04 16:14:34 +00:00
|
|
|
|
virtual void Clear()=0;
|
2011-11-07 01:29:50 +00:00
|
|
|
|
virtual bool Contains(T item)=0;
|
2010-12-04 16:14:34 +00:00
|
|
|
|
virtual void CopyTo(T array[], int arrayIndex)=0;
|
2011-11-07 01:29:50 +00:00
|
|
|
|
virtual bool Remove(T item)=0;
|
2010-12-04 16:14:34 +00:00
|
|
|
|
|
|
|
|
|
virtual int Count()=0;
|
2011-11-07 01:29:50 +00:00
|
|
|
|
virtual bool IsReadOnly()=0;
|
2010-12-04 16:14:34 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-11-07 01:29:50 +00:00
|
|
|
|
// Defines a method that a type implements to compare two objects.
|
2010-12-04 16:14:34 +00:00
|
|
|
|
template <class T>
|
|
|
|
|
interface IComparer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual int Compare(T x, T y)=0;
|
|
|
|
|
};
|
|
|
|
|
|
2011-11-07 01:29:50 +00:00
|
|
|
|
// Represents a generic collection of key/value pairs.
|
2010-12-04 16:14:34 +00:00
|
|
|
|
template <class TKey, class TValue>
|
|
|
|
|
interface IDictionary
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual void Add(TKey key, TValue value)=0;
|
|
|
|
|
virtual bool ContainsKey(TKey key)=0;
|
|
|
|
|
virtual bool Remove(TKey key)=0;
|
|
|
|
|
virtual bool TryGetValue(TKey key, out TValue value)=0;
|
|
|
|
|
|
2011-06-09 12:57:16 +00:00
|
|
|
|
virtual ICollection<TKey>& Keys()=0;
|
|
|
|
|
virtual ICollection<TValue>& Values()=0;
|
2010-12-04 16:14:34 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-11-07 01:29:50 +00:00
|
|
|
|
// Supports a simple iteration over a generic collection.
|
2010-12-04 16:14:34 +00:00
|
|
|
|
template <class T>
|
|
|
|
|
interface IEnumerator
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual T Current()=0;
|
|
|
|
|
};
|
|
|
|
|
|
2011-11-07 01:29:50 +00:00
|
|
|
|
// Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
|
2010-12-04 16:14:34 +00:00
|
|
|
|
template <class T>
|
|
|
|
|
interface IEnumerable
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-06-09 12:57:16 +00:00
|
|
|
|
virtual IEnumerator<T>& GetEnumerator()=0;
|
2010-12-04 16:14:34 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-11-07 01:29:50 +00:00
|
|
|
|
// Defines methods to support the comparison of objects for equality.
|
2010-12-04 16:14:34 +00:00
|
|
|
|
template <class T>
|
|
|
|
|
interface IEqualityComparer
|
|
|
|
|
{
|
|
|
|
|
public:
|
2010-12-27 01:01:25 +00:00
|
|
|
|
virtual bool Equals(T x, T y)=0;
|
|
|
|
|
virtual int GetHashCode(T obj)=0;
|
2010-12-04 16:14:34 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-11-07 01:29:50 +00:00
|
|
|
|
// Represents a collection of objects that can be individually accessed by index.
|
2010-12-04 16:14:34 +00:00
|
|
|
|
template <class T>
|
|
|
|
|
interface IList : public ICollection<T>
|
|
|
|
|
{
|
|
|
|
|
public:
|
2011-11-07 01:29:50 +00:00
|
|
|
|
virtual int IndexOf(T item)=0;
|
|
|
|
|
virtual void Insert(int index, T item)=0;
|
2010-12-04 16:14:34 +00:00
|
|
|
|
virtual void RemoveAt(int index)=0;
|
|
|
|
|
|
2011-11-07 01:29:50 +00:00
|
|
|
|
virtual T operator[](int index)=0;
|
2010-12-04 16:14:34 +00:00
|
|
|
|
|
2011-01-16 00:47:37 +00:00
|
|
|
|
virtual ~IList() {}
|
2010-12-04 16:14:34 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif //_SYSTEM_COLLECTIONS_GENERIC_INTERFACES_
|