From 9ef52a4929b989b126d6edd0821506817781a546 Mon Sep 17 00:00:00 2001 From: mdb Date: Sat, 26 Jul 2008 22:11:38 +0000 Subject: [PATCH] Some type parameter clarification. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2348 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/util/BaseArrayList.java | 26 +++++++++---------- src/java/com/samskivert/util/Collections.java | 24 ++++++++--------- .../com/samskivert/util/CountHashMap.java | 18 ++++++------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/java/com/samskivert/util/BaseArrayList.java b/src/java/com/samskivert/util/BaseArrayList.java index 0b5d3a0f..c6259e24 100644 --- a/src/java/com/samskivert/util/BaseArrayList.java +++ b/src/java/com/samskivert/util/BaseArrayList.java @@ -36,8 +36,8 @@ import static com.samskivert.Log.log; * functionality (which we'd just extend directly if those pig fuckers hadn't * made the instance variables private). */ -public abstract class BaseArrayList extends AbstractList - implements List, RandomAccess, Cloneable, Serializable +public abstract class BaseArrayList extends AbstractList + implements List, RandomAccess, Cloneable, Serializable { // documentation inherited from interface public int size () @@ -88,9 +88,9 @@ public abstract class BaseArrayList extends AbstractList } @SuppressWarnings("unchecked") // documentation inherited from interface - public boolean add (T o) + public boolean add (E o) { - _elements = (T[])ListUtil.add(_elements, _size, o); + _elements = (E[])ListUtil.add(_elements, _size, o); _size++; return true; } @@ -106,34 +106,34 @@ public abstract class BaseArrayList extends AbstractList } // documentation inherited from interface - public T get (int index) + public E get (int index) { rangeCheck(index, false); return _elements[index]; } // documentation inherited from interface - public T set (int index, T element) + public E set (int index, E element) { rangeCheck(index, false); - T old = _elements[index]; + E old = _elements[index]; _elements[index] = element; return old; } @SuppressWarnings("unchecked") // documentation inherited from interface - public void add (int index, T element) + public void add (int index, E element) { rangeCheck(index, true); - _elements = (T[])ListUtil.insert(_elements, index, element); + _elements = (E[])ListUtil.insert(_elements, index, element); _size++; } @SuppressWarnings("unchecked") // documentation inherited from interface - public T remove (int index) + public E remove (int index) { rangeCheck(index, false); - T oval = (T)ListUtil.remove(_elements, index); + E oval = (E)ListUtil.remove(_elements, index); _size--; return oval; } @@ -166,7 +166,7 @@ public abstract class BaseArrayList extends AbstractList public Object clone () { try { - BaseArrayList dup = (BaseArrayList)super.clone(); + BaseArrayList dup = (BaseArrayList)super.clone(); if (_elements != null) { dup._elements = _elements.clone(); } @@ -179,7 +179,7 @@ public abstract class BaseArrayList extends AbstractList } /** The array of elements in our list. */ - protected T[] _elements; + protected E[] _elements; /** The number of elements in our list. */ protected int _size; diff --git a/src/java/com/samskivert/util/Collections.java b/src/java/com/samskivert/util/Collections.java index 1646a36b..2805727e 100644 --- a/src/java/com/samskivert/util/Collections.java +++ b/src/java/com/samskivert/util/Collections.java @@ -365,12 +365,12 @@ public class Collections * default access and pointlessly preventing people from properly * reusing their code. Yay! */ - protected static class SynchronizedSet - extends SynchronizedCollection implements Set { - SynchronizedSet(Set s) { + protected static class SynchronizedSet + extends SynchronizedCollection implements Set { + SynchronizedSet(Set s) { super(s); } - SynchronizedSet(Set s, Object mutex) { + SynchronizedSet(Set s, Object mutex) { super(s, mutex); } @@ -426,18 +426,18 @@ public class Collections * default access and pointlessly preventing people from properly * reusing their code. Yay! */ - protected static class SynchronizedCollection - implements Collection { - Collection c; // Backing Collection + protected static class SynchronizedCollection + implements Collection { + Collection c; // Backing Collection Object mutex; // Object on which to synchronize - SynchronizedCollection(Collection c) { + SynchronizedCollection(Collection c) { if (c==null) throw new NullPointerException(); this.c = c; mutex = this; } - SynchronizedCollection(Collection c, Object mutex) { + SynchronizedCollection(Collection c, Object mutex) { this.c = c; this.mutex = mutex; } @@ -458,11 +458,11 @@ public class Collections synchronized(mutex) {return c.toArray(a);} } - public Iterator iterator() { + public Iterator iterator() { return c.iterator(); // Must be manually synched by user! } - public boolean add(T o) { + public boolean add(E o) { synchronized(mutex) {return c.add(o);} } public boolean remove(Object o) { @@ -472,7 +472,7 @@ public class Collections public boolean containsAll(Collection coll) { synchronized(mutex) {return c.containsAll(coll);} } - public boolean addAll(Collection coll) { + public boolean addAll(Collection coll) { synchronized(mutex) {return c.addAll(coll);} } public boolean removeAll(Collection coll) { diff --git a/src/java/com/samskivert/util/CountHashMap.java b/src/java/com/samskivert/util/CountHashMap.java index 8a99765f..97d7b661 100644 --- a/src/java/com/samskivert/util/CountHashMap.java +++ b/src/java/com/samskivert/util/CountHashMap.java @@ -191,26 +191,26 @@ public class CountHashMap extends HashMap protected Map.Entry _entry; } - protected class CountEntrySet - extends AbstractSet> + protected class CountEntrySet + extends AbstractSet> { - public CountEntrySet (Set> superset) + public CountEntrySet (Set> superset) { _superset = superset; } - public Iterator> iterator () + public Iterator> iterator () { - final Iterator> itr = _superset.iterator(); - return new Iterator>() { + final Iterator> itr = _superset.iterator(); + return new Iterator>() { public boolean hasNext () { return itr.hasNext(); } - public Entry next () + public Entry next () { - return new CountEntryImpl(itr.next()); + return new CountEntryImpl(itr.next()); } public void remove () @@ -240,6 +240,6 @@ public class CountHashMap extends HashMap CountHashMap.this.clear(); } - protected Set> _superset; + protected Set> _superset; } }