mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
rework collection interfaces for GNfaDfa.cs
This commit is contained in:
parent
a6f8dac7c6
commit
2c4ca85ba5
@ -19,7 +19,7 @@
|
||||
</TypeParams>
|
||||
<Uses />
|
||||
<Inherits>
|
||||
<Type>System.Collections.IDictionary*[K,V]*</Type>
|
||||
<Type>System.Collections.Generic.IDictionary*[K,V]*</Type>
|
||||
<!-- <Type>IList<T>, ICollection<T>,
|
||||
IEnumerable<T>, IList, ICollection, IEnumerable</Type> -->
|
||||
</Inherits>
|
||||
|
@ -8,13 +8,16 @@
|
||||
-->
|
||||
<Interface xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:www.twigletsoftware.com:schemas:txtemplate:1:0">
|
||||
<Imports>
|
||||
<Import>java.util.Collection</Import>
|
||||
<Import>CS2JNet.System.Collections.ICollection</Import>
|
||||
</Imports>
|
||||
<Java>Collection*[${T}]*</Java>
|
||||
<Java>ICollection*[${T}]*</Java>
|
||||
<Name>System.Collections.Generic.ICollection</Name>
|
||||
<TypeParams>
|
||||
<Name>T</Name>
|
||||
</TypeParams>
|
||||
<Inherits>
|
||||
<Type>>System.Collections.Generic.IEnumerable*[T]*</Type>
|
||||
</Inherits>
|
||||
<Iterable>
|
||||
<ElementType>T</ElementType>
|
||||
<Java>${expr}</Java>
|
||||
|
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
This file is
|
||||
|
||||
Copyright 2007,2008,2009,2010 Rustici Software, LLC
|
||||
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
|
||||
-->
|
||||
<Class variant="LCC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:www.twigletsoftware.com:schemas:txtemplate:1:0">
|
||||
<Imports>
|
||||
<Import>java.util.HashMap</Import>
|
||||
</Imports>
|
||||
<Java>HashMap*[${K},${V}]*</Java>
|
||||
<Name>System.Collections.Generic.Dictionary</Name>
|
||||
<TypeParams>
|
||||
<Name>K</Name>
|
||||
<Name>V</Name>
|
||||
</TypeParams>
|
||||
<Uses />
|
||||
<Inherits>
|
||||
<Type>System.Collections.Generic.IDictionary*[K,V]*</Type>
|
||||
<!-- <Type>IList<T>, ICollection<T>,
|
||||
IEnumerable<T>, IList, ICollection, IEnumerable</Type> -->
|
||||
</Inherits>
|
||||
<Iterable>
|
||||
<ElementType>KeyValuePair*[K,V]*</ElementType>
|
||||
<Java>${expr}.entrySet()</Java>
|
||||
</Iterable>
|
||||
<Methods>
|
||||
<Method>
|
||||
<Imports />
|
||||
<Java>${this:16}.put(${key}, ${value})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>K</Type>
|
||||
<Name>key</Name>
|
||||
</Param>
|
||||
<Param>
|
||||
<Type>V</Type>
|
||||
<Name>value</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
<Name>Add</Name>
|
||||
<Return>System.Void</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Imports />
|
||||
<Java>${this:16}.clear()</Java>
|
||||
<Params />
|
||||
<Name>Clear</Name>
|
||||
<Return>System.Void</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Imports />
|
||||
<Java>${this:16}.containsKey(${key})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>K</Type>
|
||||
<Name>key</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
<Name>ContainsKey</Name>
|
||||
<Return>System.Boolean</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Imports />
|
||||
<Java>${this:16}.containsValue(${value})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>V</Type>
|
||||
<Name>value</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
<Name>ContainsValue</Name>
|
||||
<Return>System.Boolean</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Imports />
|
||||
<Java>${this:16}.remove(${key})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>System.Object</Type>
|
||||
<Name>key</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
<Name>Remove</Name>
|
||||
<!-- in java actually returns the value removed -->
|
||||
<Return>System.Boolean</Return>
|
||||
</Method>
|
||||
</Methods>
|
||||
<Properties>
|
||||
<Property>
|
||||
<Imports />
|
||||
<Java>${this:16}.size()</Java>
|
||||
<Type>System.Int32</Type>
|
||||
<Name>Count</Name>
|
||||
<Get>${this:16}.size()</Get>
|
||||
</Property>
|
||||
<Property>
|
||||
<Imports>
|
||||
<Import>CS2JNet.JavaSupport.Collections.Generic.LCC.CollectionSupport</Import>
|
||||
</Imports>
|
||||
<Type>System.Collections.Generic.KeyCollection*[K]*</Type>
|
||||
<Name>Keys</Name>
|
||||
<Get>CollectionSupport.mk(${this:16}.keySet())</Get>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events />
|
||||
<Indexers>
|
||||
<Indexer>
|
||||
<Imports />
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>System.Object</Type>
|
||||
<Name>key</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
<Type>V</Type>
|
||||
<Get>${this:16}.get(${key})</Get>
|
||||
<Set>${this:16}.put(${key}, ${value})</Set>
|
||||
</Indexer>
|
||||
</Indexers>
|
||||
<Constructors>
|
||||
<Constructor>
|
||||
<Imports />
|
||||
<Java>new HashMap*[${K},${V}]*()</Java>
|
||||
<Params />
|
||||
</Constructor>
|
||||
</Constructors>
|
||||
<Fields />
|
||||
<Casts />
|
||||
<UnaryOps />
|
||||
<BinaryOps />
|
||||
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>qbxkvItrQBq06TjO7qOtFI8C/q0=</DigestValue></Reference></SignedInfo><SignatureValue>RcwnIhyoghrIJVGfVld2S5OkoSKruLMH/elhtAB+HTovqtoa+1Sdb1cVkFbu8Vb4YpAubmZh6Kv87UYSjKb50c15xCsx3naC7Je/qZ68rac206rokoqKiLXAV5M5C+Pr0q8gFyQK60WohWma7DrsO+B5ByXYR1UORm6Tk4WO04Q=</SignatureValue></Signature></Class>
|
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
This file is
|
||||
|
||||
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
|
||||
-->
|
||||
<Interface variant="LCC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:www.twigletsoftware.com:schemas:txtemplate:1:0">
|
||||
<Imports>
|
||||
<Import>CS2JNet.System.Collections.LCC.ICollection</Import>
|
||||
</Imports>
|
||||
<Java>ICollection*[${T}]*</Java>
|
||||
<Name>System.Collections.Generic.ICollection</Name>
|
||||
<TypeParams>
|
||||
<Name>T</Name>
|
||||
</TypeParams>
|
||||
<Inherits>
|
||||
<Type>System.Collections.Generic.IEnumerable*[T]*</Type>
|
||||
</Inherits>
|
||||
<Iterable>
|
||||
<ElementType>T</ElementType>
|
||||
<Java>${expr}</Java>
|
||||
</Iterable>
|
||||
<Properties>
|
||||
</Properties>
|
||||
<Methods>
|
||||
<Method>
|
||||
<Imports />
|
||||
<Java>${this:16}.add(${arg})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>T</Type>
|
||||
<Name>arg</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
<Name>Add</Name>
|
||||
<Return>System.Int32</Return>
|
||||
</Method>
|
||||
</Methods>
|
||||
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>E8HIpKiRknOratBbxt4a71EId0E=</DigestValue></Reference></SignedInfo><SignatureValue>bqvpolcous2/NZYPel/paViJS5fRwPaIvj75jVeZg70SnvhIFVNstqctcVLe2mw52NihU5aIVD3Pl1E5ZCeZbXs15yeg9B2CG//EbCpSXGO/a9iLa0aZhv4O63vLJAqBqT1tqKj+Z8FXIJxbwo4rtwnNHH7rqUAMsg3GfojAmS8=</SignatureValue></Signature></Interface>
|
@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
This file is
|
||||
|
||||
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
|
||||
-->
|
||||
<Interface variant="LCC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:www.twigletsoftware.com:schemas:txtemplate:1:0">
|
||||
<Imports>
|
||||
<Import>java.util.Map</Import>
|
||||
</Imports>
|
||||
<Java>Map*[${K},${V}]*</Java>
|
||||
<Name>System.Collections.Generic.IDictionary</Name>
|
||||
<TypeParams>
|
||||
<Name>K</Name>
|
||||
<Name>V</Name>
|
||||
</TypeParams>
|
||||
<Iterable>
|
||||
<ElementType>System.Collections.Generic.KeyValuePair*[K,V]*</ElementType>
|
||||
<Java>${expr}.entrySet()</Java>
|
||||
</Iterable>
|
||||
<Methods>
|
||||
<Method>
|
||||
<Imports />
|
||||
<Java>${this:16}.put(${key}, ${value})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>K</Type>
|
||||
<Name>key</Name>
|
||||
</Param>
|
||||
<Param>
|
||||
<Type>V</Type>
|
||||
<Name>value</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
<Name>Add</Name>
|
||||
<Return>System.Void</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Imports />
|
||||
<Java>${this:16}.clear()</Java>
|
||||
<Params />
|
||||
<Name>Clear</Name>
|
||||
<Return>System.Void</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Imports />
|
||||
<Java>${this:16}.containsKey(${key})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>K</Type>
|
||||
<Name>key</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
<Name>ContainsKey</Name>
|
||||
<Return>System.Boolean</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Imports />
|
||||
<Java>${this:16}.remove(${key})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>K</Type>
|
||||
<Name>key</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
<Name>Remove</Name>
|
||||
<!-- in java actually returns the value removed -->
|
||||
<Return>System.Boolean</Return>
|
||||
</Method>
|
||||
</Methods>
|
||||
<Indexers>
|
||||
<Indexer>
|
||||
<Imports />
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>K</Type>
|
||||
<Name>key</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
<Type>V</Type>
|
||||
<Get>${this:16}.get(${key})</Get>
|
||||
<Set>${this:16}.put(${key}, ${value})</Set>
|
||||
</Indexer>
|
||||
</Indexers>
|
||||
<Properties>
|
||||
<Property>
|
||||
<Imports>
|
||||
<Import>CS2JNet.JavaSupport.Collections.Generic.LCC.CollectionSupport</Import>
|
||||
</Imports>
|
||||
<Type>System.Collections.Generic.ICollection*[K]*</Type>
|
||||
<Name>Keys</Name>
|
||||
<Get>CollectionSupport.mk(${this:16}.keySet())</Get>
|
||||
</Property>
|
||||
<Property>
|
||||
<Imports />
|
||||
<Type>System.Collections.Generic.ICollection*[V]*</Type>
|
||||
<Name>Values</Name>
|
||||
<Get>${this:16}.values()</Get>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>BBHaGzWIzkVajkMtIotxcu6p5VY=</DigestValue></Reference></SignedInfo><SignatureValue>WOOzmkxA0yBm1tFVetTcQxQc7SztNyQygCPbn5vaHLtHI/MoQMuTuytu5BrGb4UJ7KG68galgfmWUlUD99Txs44X+XdHA7wY0XcAUwXHV+/uti6FicyhHw7mDr9Bj4+Rjq4RIA2I0gS5P25V9nMEIEQCD3/jjc+wc4Lt5AHw/b4=</SignatureValue></Signature></Interface>
|
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
This file is
|
||||
|
||||
Copyright 2007,2008,2009,2010 Rustici Software, LLC
|
||||
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
|
||||
-->
|
||||
<Class variant="LCC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:www.twigletsoftware.com:schemas:txtemplate:1:0">
|
||||
<Imports>
|
||||
<Import>CS2JNet.JavaSupport.Collections.Generic.CollectionSupport</Import>
|
||||
</Imports>
|
||||
<Java>CollectionSupport*[${T}]*</Java>
|
||||
<!-- Actually: System.Collections.Generic.Dictionary<TKey, TValue>.KeyCollection -->
|
||||
<Name>System.Collections.Generic.KeyCollection</Name>
|
||||
<TypeParams>
|
||||
<Name>T</Name>
|
||||
</TypeParams>
|
||||
<Uses />
|
||||
<Inherits>
|
||||
</Inherits>
|
||||
<Iterable>
|
||||
<ElementType>T</ElementType>
|
||||
<Java>${expr}</Java>
|
||||
</Iterable>
|
||||
<Methods>
|
||||
<Method>
|
||||
<Imports>
|
||||
<Import>CS2JNet.System.Collections.Generic.KeyCollectionSupport</Import>
|
||||
</Imports>
|
||||
<Java>${this:16}.copyTo(${array}, ${index})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>T[]</Type>
|
||||
<Name>array</Name>
|
||||
</Param>
|
||||
<Param>
|
||||
<Type>System.Int32</Type>
|
||||
<Name>index</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
<Name>CopyTo</Name>
|
||||
<Return>System.Void</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Imports>
|
||||
<Import>CS2JNet.JavaSupport.Collections.Generic.LCC.EnumeratorSupport</Import>
|
||||
</Imports>
|
||||
<Java>new EnumeratorSupport*[T]*(${this:16}.iterator())</Java>
|
||||
<Params>
|
||||
</Params>
|
||||
<Name>GetEnumerator</Name>
|
||||
<Return>System.Collections.Generic.IEnumerator*[T]*</Return>
|
||||
</Method>
|
||||
</Methods>
|
||||
<Properties>
|
||||
<Property>
|
||||
<Imports />
|
||||
<Java>${this:16}.size()</Java>
|
||||
<Type>System.Int32</Type>
|
||||
<Name>Count</Name>
|
||||
<Get>${this:16}.size()</Get>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events />
|
||||
<Indexers>
|
||||
</Indexers>
|
||||
<Constructors>
|
||||
</Constructors>
|
||||
<Fields />
|
||||
<Casts />
|
||||
<UnaryOps />
|
||||
<BinaryOps />
|
||||
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>cUmprobnXdg5Nhlk8vAMJ2coyAo=</DigestValue></Reference></SignedInfo><SignatureValue>XKTAn+4HQ4/anCQ8npTwr1Yrf3AxZc69HuV6muqqws96mCfCvaUhIqmlc2rZsw4CaXd+0bkFunIbLLgqHBaOePb1eKyp29uHhXODO/68lb8kfcPHB4aGO5LKWNPGw3mQoKK4RjuuRdOWZpx1wg7P5BGr+bGdX/gVk8pUUhHzDHs=</SignatureValue></Signature></Class>
|
@ -0,0 +1,175 @@
|
||||
/*
|
||||
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Author(s):
|
||||
|
||||
Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
*/
|
||||
package CS2JNet.JavaSupport.Collections.Generic.LCC;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.lang.NullArgumentException;
|
||||
|
||||
import CS2JNet.System.ArgumentException;
|
||||
import CS2JNet.System.Collections.LCC.ICollection;
|
||||
import CS2JNet.System.Collections.LCC.IEnumerator;
|
||||
|
||||
/**
|
||||
* A concrete implementation of .Net's ICollection that wraps a Collection
|
||||
*
|
||||
* @author keving
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public class CollectionSupport<T> implements ICollection<T> {
|
||||
|
||||
private Collection<T> myCollection = null;
|
||||
|
||||
public CollectionSupport(Collection<T> inColl) {
|
||||
myCollection = inColl;
|
||||
}
|
||||
|
||||
public static <S> CollectionSupport<S> mk(Collection<S> inColl) {
|
||||
return new CollectionSupport<S>(inColl);
|
||||
}
|
||||
|
||||
|
||||
public Iterator<T> iterator() {
|
||||
return myCollection.iterator();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean add(T arg0) {
|
||||
return myCollection.add(arg0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends T> arg0) {
|
||||
return myCollection.addAll(arg0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
myCollection.clear();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean contains(Object arg0) {
|
||||
return myCollection.contains(arg0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> arg0) {
|
||||
return myCollection.containsAll(arg0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return myCollection.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean remove(Object arg0) {
|
||||
return myCollection.remove(arg0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> arg0) {
|
||||
return myCollection.removeAll(arg0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> arg0) {
|
||||
return myCollection.retainAll(arg0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return myCollection.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return myCollection.toArray();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <S> S[] toArray(S[] arg0) {
|
||||
return myCollection.toArray(arg0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean Contains(T x) throws Exception {
|
||||
return myCollection.contains(x);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void Add(T x) throws Exception {
|
||||
myCollection.add(x);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean Remove(T x) throws Exception {
|
||||
return myCollection.remove(x);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void Clear() throws Exception {
|
||||
myCollection.clear();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IEnumerator<T> getEnumerator() throws Exception {
|
||||
return new EnumeratorSupport<T>(myCollection.iterator());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void copyTo(T[] arr, int i) throws Exception {
|
||||
if (arr == null) {
|
||||
throw new NullArgumentException("arr");
|
||||
}
|
||||
if (i < 0 || i + myCollection.size() > arr.length) {
|
||||
throw new ArgumentException("i");
|
||||
}
|
||||
int idx = 0;
|
||||
for (T e : this) {
|
||||
arr[i+idx] = e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright 2007,2008,2009,2010 Rustici Software, LLC
|
||||
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Author(s):
|
||||
|
||||
Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
*/
|
||||
package CS2JNet.JavaSupport.Collections.Generic.LCC;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import CS2JNet.JavaSupport.CS2JRunTimeException;
|
||||
import CS2JNet.System.Collections.LCC.IEnumerator;
|
||||
|
||||
/**
|
||||
* A concrete implementation of .Net's Enumerator that wraps an Iterator
|
||||
*
|
||||
* @author keving
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public class EnumeratorSupport<T> implements IEnumerator<T> {
|
||||
|
||||
private Iterator<T> myIterator = null;
|
||||
private T myCurrent = null;
|
||||
|
||||
public static <S> EnumeratorSupport<S> mk(Iterator<S> inIt) {
|
||||
return new EnumeratorSupport<S>(inIt);
|
||||
}
|
||||
|
||||
public EnumeratorSupport(Iterator<T> it) {
|
||||
myIterator = it;
|
||||
}
|
||||
|
||||
public T getCurrent() throws Exception {
|
||||
return myCurrent;
|
||||
}
|
||||
|
||||
public boolean moveNext() throws Exception {
|
||||
boolean hasNext = myIterator.hasNext();
|
||||
if (hasNext) {
|
||||
myCurrent = myIterator.next();
|
||||
}
|
||||
return hasNext;
|
||||
}
|
||||
|
||||
public void reset() throws Exception {
|
||||
throw new CS2JRunTimeException("CS2J: IEnumerator does not yet support Reset() operation");
|
||||
}
|
||||
|
||||
public Iterator<T> iterator() {
|
||||
return myIterator;
|
||||
}
|
||||
|
||||
}
|
@ -27,7 +27,7 @@ import java.util.Collection;
|
||||
* @author kevin.glynn@twigletsoftware.com
|
||||
*
|
||||
*/
|
||||
public interface ICollection<T> extends Collection<T> {
|
||||
public interface ICollection<T> extends IEnumerable<T>,Collection<T> {
|
||||
|
||||
|
||||
public boolean Contains(T x) throws Exception;
|
||||
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Author(s):
|
||||
|
||||
Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
*/
|
||||
|
||||
package CS2JNet.System.Collections.LCC;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
* Mimics Net's IEnumerator interface
|
||||
*
|
||||
* @author keving
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface ICollection<T> extends IEnumerable<T>,Collection<T> {
|
||||
|
||||
|
||||
public boolean Contains(T x) throws Exception;
|
||||
|
||||
public void Add(T x) throws Exception;
|
||||
|
||||
public boolean Remove(T x) throws Exception;
|
||||
|
||||
public void Clear() throws Exception;
|
||||
|
||||
public IEnumerator<T> getEnumerator() throws Exception;
|
||||
|
||||
public void copyTo(T[] arr, int i) throws Exception;
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user