[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnetlib/runtime/System/Collections/Generic Compare
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnetlib/runtime/System/Collections/Generic Comparer.cs, NONE, 1.1 Dictionary.cs, NONE, 1.1 ICollection.cs, NONE, 1.1 IComparable.cs, NONE, 1.1 IComparer.cs, NONE, 1.1 IDictionary.cs, NONE, 1.1 IEnumerable.cs, NONE, 1.1 IEnumerator.cs, NONE, 1.1 IKeyComparer.cs, NONE, 1.1 IList.cs, NONE, 1.1 KeyValuePair.cs, NONE, 1.1 |
Date: |
Thu, 06 Nov 2003 21:48:38 +0000 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Collections/Generic
In directory subversions:/tmp/cvs-serv6026/runtime/System/Collections/Generic
Added Files:
Comparer.cs Dictionary.cs ICollection.cs IComparable.cs
IComparer.cs IDictionary.cs IEnumerable.cs IEnumerator.cs
IKeyComparer.cs IList.cs KeyValuePair.cs
Log Message:
Check in the beginnings of the "System.Collections.Generic" namespace.
--- NEW FILE: IComparer.cs ---
/*
* IComparer.cs - Implementation of the
* "System.Collections.Generic.IComparer" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Collections.Generic
{
#if CONFIG_GENERICS
using System.Runtime.InteropServices;
#if !ECMA_COMPAT
[ComVisible(false)]
#endif
[CLSCompliant(false)]
public interface IComparer<T>
{
int Compare(T x, T y);
}; // interface IComparer<T>
#endif // CONFIG_GENERICS
}; // namespace System.Collections.Generic
--- NEW FILE: IEnumerator.cs ---
/*
* IEnumerator.cs - Implementation of the
* "System.Collections.Generic.IEnumerator" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Collections.Generic
{
#if CONFIG_GENERICS
using System.Runtime.InteropServices;
#if !ECMA_COMPAT
[ComVisible(false)]
#endif
[CLSCompliant(false)]
public interface IEnumerator<T>
{
bool MoveNext();
T Current { get; }
}; // interface IEnumerator<T>
#endif // CONFIG_GENERICS
}; // namespace System.Collections.Generic
--- NEW FILE: ICollection.cs ---
/*
* ICollection.cs - Implementation of the
* "System.Collections.Generic.ICollection" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Collections.Generic
{
#if CONFIG_GENERICS
using System.Runtime.InteropServices;
#if !ECMA_COMPAT
[ComVisible(false)]
#endif
[CLSCompliant(false)]
public interface ICollection<T> : IEnumerable<T>
{
void CopyTo(T[] array, int arrayIndex);
int Count { get; }
}; // interface ICollection<T>
#endif // CONFIG_GENERICS
}; // namespace System.Collections.Generic
--- NEW FILE: KeyValuePair.cs ---
/*
* KeyValuePair.cs - Implementation of the
* "System.Collections.Generic.KeyValuePair" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Collections.Generic
{
#if CONFIG_GENERICS
using System.Runtime.InteropServices;
#if !ECMA_COMPAT
[ComVisible(false)]
#endif
[CLSCompliant(false)]
public struct KeyValuePair<K,V>
{
// Internal state.
private K key;
private V value;
// Constructor.
public KeyValuePair(K key, V value)
{
this.key = key;
this.value = value;
}
// Properties.
public K Key
{
get
{
return key;
}
set
{
key = value;
}
}
public V Value
{
get
{
return this.value;
}
set
{
this.value = value;
}
}
}; // struct KeyValuePair<K,V>
#endif // CONFIG_GENERICS
}; // namespace System.Collections.Generic
--- NEW FILE: IEnumerable.cs ---
/*
* IEnumerable.cs - Implementation of the
* "System.Collections.Generic.IEnumerable" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Collections.Generic
{
#if CONFIG_GENERICS
using System.Runtime.InteropServices;
#if !ECMA_COMPAT
[ComVisible(false)]
#endif
[CLSCompliant(false)]
public interface IEnumerable<T>
{
IEnumerator<T> GetEnumerator();
}; // interface IEnumerable<T>
#endif // CONFIG_GENERICS
}; // namespace System.Collections.Generic
--- NEW FILE: Dictionary.cs ---
/*
* Dictionary.cs - Implementation of the
* "System.Collections.Generic.Dictionary" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Collections.Generic
{
#if CONFIG_GENERICS
using System.Runtime.InteropServices;
#if !ECMA_COMPAT
[ComVisible(false)]
#endif
[CLSCompliant(false)]
public class Dictionary<K,V>
: System.Collections.ICollection, ICollection< KeyValuePair<K,V> >,
System.Collections.IDictionary, IDictionary<K,V>,
System.Collections.IEnumerable, IEnumerable< KeyValuePair<K,V> >
{
// Constructors.
[TODO]
public Dictionary()
{
// TODO
}
[TODO]
public Dictionary(int capacity)
{
// TODO
}
[TODO]
public Dictionary(IKeyComparer comparer)
{
// TODO
}
[TODO]
public Dictionary(int capacity, IKeyComparer comparer)
{
// TODO
}
[TODO]
public Dictionary(IDictionary<K,V> dictionary)
{
// TODO
}
[TODO]
public Dictionary(IDictionary<K,V> dictionary, IKeyComparer comparer)
{
// TODO
}
// Implement the non-generic ICollection interface.
[TODO]
void System.Collections.ICollection.CopyTo(Array array, int index)
{
// TODO
}
int System.Collections.ICollection.Count
{
get
{
return Count;
}
}
bool System.Collections.ICollection.IsSynchronized
{
get
{
return false;
}
}
Object System.Collections.ICollection.SyncRoot
{
get
{
return this;
}
}
// Implement the generic ICollection<KeyValuePair<K,V>> interface.
[TODO]
void ICollection< KeyValuePair<K,V> >.CopyTo
(KeyValuePair<K,V> array, int index)
{
// TODO
}
[TODO]
public int Count
{
get
{
// TODO
return 0;
}
}
// Implement the non-generic IDictionary interface.
[TODO]
void System.Collections.IDictionary.Add(Object key, Object value)
{
// TODO
}
void System.Collections.IDictionary.Clear()
{
Clear();
}
bool System.Collections.IDictionary.Contains(Object key)
{
if(key == null)
{
return false;
}
else if(key is K)
{
return ContainsKey((K)key);
}
else
{
return false;
}
}
[TODO]
new IDictionaryEnumerator System.Collections.IDictionary.GetEnumerator()
{
// TODO
return null;
}
void System.Collections.IDictionary.Remove(Object key)
{
if(key != null && key is K)
{
Remove((K)key);
}
}
bool System.Collections.IDictionary.IsFixedSize
{
get
{
return false;
}
}
bool System.Collections.IDictionary.IsReadOnly
{
get
{
return false;
}
}
Object System.Collections.IDictionary.this[Object key]
{
get
{
if(key == null)
{
throw new
ArgumentNullException("key");
}
else if(key is K)
{
return this[(K)key];
}
else
{
return null;
}
}
set
{
if(key == null)
{
throw new
ArgumentNullException("key");
}
else
{
this[(K)key] = (V)value;
}
}
}
ICollection System.Collections.IDictionary.Keys
{
get
{
return (ICollection)Keys;
}
}
ICollection System.Collections.IDictionary.Values
{
get
{
return (ICollection)Values;
}
}
// Implement the generic IDictionary<K,V> interface.
[TODO]
public void Add(K key, V value)
{
// TODO
}
[TODO]
public void Clear()
{
// TODO
}
[TODO]
public bool ContainsKey(K key)
{
// TODO
return false;
}
[TODO]
public bool Remove(K key)
{
// TODO
return false;
}
bool IDictionary<K,V>.IsFixedSize
{
get
{
return false;
}
}
bool IDictionary<K,V>.IsReadOnly
{
get
{
return false;
}
}
[TODO[
V IDictionary.this[K key]
{
get
{
// TODO
throw new NotImplementedException();
}
set
{
// TODO
}
}
[TODO]
public ICollection<K> Keys
{
get
{
// TODO
return null;
}
}
[TODO]
public ICollection<V> Values
{
get
{
// TODO
return null;
}
}
// Implement the non-generic IEnumerable interface.
System.Collections.IEnumerator
System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
// Implement the generic IEnumerable< KeyValuePair<K,V> > interface.
IEnumerator< KeyValuePair<K,V> >
IEnumerable< KeyValuePair<K,V> >.GetEnumerator()
{
return GetEnumerator();
}
// Determine if this dictionary contains a particular value.
[TODO]
public bool ContainsValue(V value)
{
// TODO
return false;
}
// Get an enumerator for this dictionary.
public Enumerator<K,V> GetEnumerator()
{
// TODO
return new Enumerator(this);
}
// Enumerator class for generic dictionaries.
public struct Enumerator<K,V>
: System.Collections.IEnumerator, IEnumerator<
KeyValuePair<K,V> >
{
// Constructor.
[TODO]
internal Enumerator(Dictionary<K,V> dictionary)
{
// TODO
}
// Dispose of this enumerator.
public void Dispose()
{
// TODO
}
// Implement the non-generic IEnumerator interface.
bool System.Collections.IEnumerator.MoveNext()
{
return MoveNext();
}
void System.Collections.IEnumerator.Reset()
{
throw new InvalidOperationException();
}
Object System.Collections.IEnumerator.Current
{
get
{
return Current;
}
}
// Implement the generic IEnumerator< KeyValuePair<K,V> >
interface.
public bool MoveNext()
{
// TODO
return false;
}
public KeyValuePair<K,V> Current
{
get
{
// TODO
throw new
NotImplementedException();
}
}
}; // struct Enumerator<K,V>
}; // class IDictionary<K,V>
#endif // CONFIG_GENERICS
}; // namespace System.Collections.Generic
--- NEW FILE: IList.cs ---
/*
* IList.cs - Implementation of the
* "System.Collections.Generic.IList" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Collections.Generic
{
#if CONFIG_GENERICS
using System.Runtime.InteropServices;
#if !ECMA_COMPAT
[ComVisible(false)]
#endif
[CLSCompliant(false)]
public interface IList<T> : ICollection<T>
{
int Add(T item);
void Clear();
bool Contains(T item);
int IndexOf(T item);
void Insert(int index, T item);
void Remove(T item);
void RemoveAt(int index);
bool IsFixedSize { get; }
bool IsReadOnly { get; }
T this[int index] { get; set; }
}; // interface IList<T>
#endif // CONFIG_GENERICS
}; // namespace System.Collections.Generic
--- NEW FILE: IKeyComparer.cs ---
/*
* IKeyComparer.cs - Implementation of the
* "System.Collections.Generic.IKeyComparer" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Collections.Generic
{
#if CONFIG_GENERICS
using System.Runtime.InteropServices;
#if !ECMA_COMPAT
[ComVisible(false)]
#endif
[CLSCompliant(false)]
public interface IKeyComparer<T>
{
bool Equals(T x, T y);
int GetHashCode(T obj);
}; // interface IKeyComparer<T>
#endif // CONFIG_GENERICS
}; // namespace System.Collections.Generic
--- NEW FILE: IComparable.cs ---
/*
* IComparable.cs - Implementation of the
* "System.Collections.Generic.IComparable" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Collections.Generic
{
#if CONFIG_GENERICS
using System.Runtime.InteropServices;
#if !ECMA_COMPAT
[ComVisible(false)]
#endif
[CLSCompliant(false)]
public interface IComparable<T>
{
int CompareTo(T other);
}; // interface IComparable<T>
#endif // CONFIG_GENERICS
}; // namespace System.Collections.Generic
--- NEW FILE: IDictionary.cs ---
/*
* IDictionary.cs - Implementation of the
* "System.Collections.Generic.IDictionary" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Collections.Generic
{
#if CONFIG_GENERICS
using System.Runtime.InteropServices;
#if !ECMA_COMPAT
[ComVisible(false)]
#endif
[CLSCompliant(false)]
public interface IDictionary<K,V> : ICollection< KeyValuePair<K,V> >
{
void Add(K key, V value);
void Clear();
bool ContainsKey(K key);
bool Remove(K key);
bool IsFixedSize { get; }
bool IsReadOnly { get; }
V this[K key] { get; set; }
ICollection<K> Keys;
ICollection<V> Values;
}; // interface IDictionary<K,V>
#endif // CONFIG_GENERICS
}; // namespace System.Collections.Generic
--- NEW FILE: Comparer.cs ---
/*
* Comparer.cs - Implementation of the
* "System.Collections.Generic.Comparer" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Collections.Generic
{
#if CONFIG_GENERICS
using System.Globalization;
using System.Runtime.InteropServices;
#if !ECMA_COMPAT
[ComVisible(false)]
#endif
[CLSCompliant(false)]
public class Comparer<T> : IComparer<T>
{
// Internal state.
private CompareInfo info;
// Constructor.
public Comparer(CultureInfo culture)
{
if(culture == null)
{
throw new
ArgumentNullException("culture");
}
info = culture.CompareInfo;
}
// Compare two elements.
public int Compare(T x, T y)
{
// Handle the null cases first if T is a
reference type.
if(!(typeof(T).IsValueType))
{
if(x == null)
{
if(y == null)
{
return 0;
}
else
{
return -1;
}
}
else if(y == null)
{
return 1;
}
}
// Handle the string case, using the culture.
if(x is String && y is String)
{
return info.Compare((String)x,
(String)y);
}
// See if one of the elements is IComparable<T>.
if(x is IComparable<T>)
{
return ((IComparable<T>)x).CompareTo(y);
}
if(y is IComparable<T>)
{
return
-(((IComparable<T>)y).CompareTo(x));
}
// See if one of the elements is IComparable.
if(x is System.Collections.IComparable)
{
return
((System.Collections.IComparable)x).CompareTo(y);
}
if(y is System.Collections.IComparable)
{
return
-(((System.Collections.IComparable)y).CompareTo(x));
}
// Cannot compare the elements.
throw new
ArgumentException(_("Arg_ABMustBeComparable"));
}
}; // class Comparer<T>
#endif // CONFIG_GENERICS
}; // namespace System.Collections.Generic
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnetlib/runtime/System/Collections/Generic Comparer.cs, NONE, 1.1 Dictionary.cs, NONE, 1.1 ICollection.cs, NONE, 1.1 IComparable.cs, NONE, 1.1 IComparer.cs, NONE, 1.1 IDictionary.cs, NONE, 1.1 IEnumerable.cs, NONE, 1.1 IEnumerator.cs, NONE, 1.1 IKeyComparer.cs, NONE, 1.1 IList.cs, NONE, 1.1 KeyValuePair.cs, NONE, 1.1,
Rhys Weatherley <address@hidden> <=