[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/System/Collections/Specialized Makefi
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/System/Collections/Specialized Makefile,NONE,1.1 StringCollection.cs,NONE,1.1 StringDictionary.cs,NONE,1.1 StringEnumerator.cs,NONE,1.1 |
Date: |
Wed, 06 Nov 2002 22:54:40 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System/Collections/Specialized
In directory subversions:/tmp/cvs-serv29656/System/Collections/Specialized
Added Files:
Makefile StringCollection.cs StringDictionary.cs
StringEnumerator.cs
Log Message:
Implement some missing classes from "System.Collections.Specialized".
--- NEW FILE ---
all:
(cd ../..;make)
--- NEW FILE ---
/*
* StringCollection.cs - Implementation of
* "System.Collections.Specialized.StringCollection".
*
* Copyright (C) 2002 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.Specialized
{
using System;
using System.Collections;
public class StringCollection : IList, ICollection, IEnumerable
{
// Internal state.
private ArrayList list;
// Constructor.
public StringCollection()
{
list = new ArrayList();
}
// Implement the IList interface.
int IList.Add(Object value)
{
return list.Add((String)value);
}
public void Clear()
{
list.Clear();
}
bool IList.Contains(Object value)
{
if(value == null || value is String)
{
return list.Contains(value);
}
else
{
return false;
}
}
int IList.IndexOf(Object value)
{
if(value == null || value is String)
{
return list.IndexOf(value);
}
else
{
return -1;
}
}
void IList.Insert(int index, Object value)
{
list.Insert(index, (String)value);
}
void IList.Remove(Object value)
{
if(value == null || value is String)
{
list.Remove(value);
}
}
public void RemoveAt(int index)
{
list.RemoveAt(index);
}
bool IList.IsFixedSize
{
get
{
return false;
}
}
public bool IsReadOnly
{
get
{
return false;
}
}
Object IList.this[int index]
{
get
{
return list[index];
}
set
{
list[index] = (String)value;
}
}
// Implement the ICollection interface.
void ICollection.CopyTo(Array array, int index)
{
list.CopyTo(array, index);
}
public int Count
{
get
{
return list.Count;
}
}
public bool IsSynchronized
{
get
{
return false;
}
}
public Object SyncRoot
{
get
{
return list;
}
}
// Implement the IEnumerable interface.
IEnumerator IEnumerable.GetEnumerator()
{
return list.GetEnumerator();
}
// Access a specific item within this string collection.
public String this[int index]
{
get
{
return (String)(list[index]);
}
set
{
list[index] = value;
}
}
// Add a string to this collection.
public int Add(String value)
{
return list.Add(value);
}
// Add a range of strings to this collection.
public void AddRange(String[] value)
{
list.AddRange(value);
}
// Determine if this string collection contains a specific value.
public bool Contains(String value)
{
return list.Contains(value);
}
// Copy the contents of this string collection to a string array.
public void CopyTo(String[] array, int index)
{
list.CopyTo(array, index);
}
// Get an enumerator for this string collection.
public StringEnumerator GetEnumerator()
{
return new
StringEnumerator(list.GetEnumerator());
}
// Get the index of a specific value within this string collection.
public int IndexOf(String value)
{
return list.IndexOf(value);
}
// Insert a string into this collection at a specific location.
public void Insert(int index, String value)
{
list.Insert(index, value);
}
// Remove a string from this collection.
public void Remove(String value)
{
list.Remove(value);
}
}; // class StringCollection
}; // namespace System.Collections.Specialized
--- NEW FILE ---
/*
* StringDictionary.cs - Implementation of
* "System.Collections.Specialized.StringDictionary".
*
* Copyright (C) 2002 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.Specialized
{
using System;
using System.Collections;
public class StringDictionary : IEnumerable
{
// Internal state.
private Hashtable hash;
// Constructor.
public StringDictionary()
{
hash = new Hashtable();
}
// Get the number of key-value pairs in the dictionary.
public virtual int Count
{
get
{
return hash.Count;
}
}
// Determine if this string dictionary is synchronized.
public virtual bool IsSynchronized
{
get
{
return false;
}
}
// Get or set an item in this string dictionary.
public virtual String this[String key]
{
get
{
return (String)(hash[key]);
}
set
{
hash[key] = value;
}
}
// Get the list of all keys in this string dictionary.
public virtual ICollection Keys
{
get
{
return hash.Keys;
}
}
// Get the synchronization root for this string dictionary.
public Object SyncRoot
{
get
{
return hash;
}
}
// Get the list of all values in this string dictionary.
public virtual ICollection Values
{
get
{
return hash.Values;
}
}
// Add an entry to this string dictionary.
public virtual void Add(String key, String value)
{
hash.Add(key, value);
}
// Remove all entries from the string dictionary.
public virtual void Clear()
{
hash.Clear();
}
// Determine if this string dictionary contains a specific key.
public virtual bool ContainsKey(String key)
{
return hash.ContainsKey(key);
}
// Determine if this string dictionary contains a specific value.
public virtual bool ContainsValue(String value)
{
return hash.ContainsValue(value);
}
// Copy all of the members in this string dictionary to an array.
public virtual void CopyTo(Array array, int index)
{
hash.CopyTo(array, index);
}
// Implement the IEnumerable interface.
public virtual IEnumerator GetEnumerator()
{
return hash.GetEnumerator();
}
// Remove a member with a specific key from this string dictionary.
public void Remove(String key)
{
hash.Remove(key);
}
}; // class StringDictionary
}; // namespace System.Collections.Specialized
--- NEW FILE ---
/*
* StringEnumerator.cs - Implementation of
* "System.Collections.Specialized.StringEnumerator".
*
* Copyright (C) 2002 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.Specialized
{
using System;
using System.Collections;
public class StringEnumerator
{
// Internal state;
private IEnumerator e;
// Constructor.
internal StringEnumerator(IEnumerator e)
{
this.e = e;
}
// Get the current element as a string.
public String Current
{
get
{
return (String)(e.Current);
}
}
// Move to the next string in the collection.
public bool MoveNext()
{
return e.MoveNext();
}
// Reset to the beginning of the collection.
public void Reset()
{
e.Reset();
}
}; // class StringEnumerator
}; // namespace System.Collections.Specialized
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/System/Collections/Specialized Makefile,NONE,1.1 StringCollection.cs,NONE,1.1 StringDictionary.cs,NONE,1.1 StringEnumerator.cs,NONE,1.1,
Rhys Weatherley <address@hidden> <=