Просмотр исходного кода

removed SingleCollections & unused AIdentSet

Ranides Atterwim 10 лет назад
Родитель
Сommit
0c401b3247

+ 0 - 48
assira/src/main/java/net/ranides/assira/collection/sets/AIdentSet.java

@@ -1,48 +0,0 @@
-/*
- *  @author Ranides Atterwim <ranides@gmail.com>
- *  @copyright Ranides Atterwim
- *  @license WTFPL
- *  @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.collection.sets;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * An abstract class with hashcode suitable for all "identity containers".
- * @author Ranides Atterwim <ranides@gmail.com>
- * @param <K> 
- */
-public abstract class AIdentSet<K> extends ASet<K> implements Collection<K>, Set<K> {
-
-    protected AIdentSet() {
-        // do nothing
-    }
-
-    /**
-     * Returns a hash code for this set. The hash code of a set is computed 
-     * by summing the hash codes of its elements because order should not change
-     * result.
-     * @return a hash code for this set.
-     */
-    @Override
-    public int hashCode() {
-        int h = 0, n = size();
-        Iterator<K> i = iterator();
-        K item;
-        while (n-- != 0) {
-            item = i.next();
-            h += ((item) == null ? 0 : System.identityHashCode(item));
-        }
-        return h;
-    }
-    
-    @Override
-    @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
-    public boolean equals(Object other) {
-        return super.equals(other);
-    }
-    
-}

+ 0 - 137
assira/src/main/java/net/ranides/assira/collection/utils/SingleCollections.java

@@ -1,137 +0,0 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
-package net.ranides.assira.collection.utils;
-
-import java.util.NoSuchElementException;
-import net.ranides.assira.collection.arrays.ArrayAllocator;
-import net.ranides.assira.collection.iterators.IntListIterator;
-import net.ranides.assira.collection.lists.IntArrayList;
-import net.ranides.assira.collection.lists.IntList;
-
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
-public final class SingleCollections {
-    
-    private SingleCollections() {
-        // utility class
-    }
-    
-    public static IntList list(int value) {
-        return new SIntList(value);
-    }
-    
-    public static IntListIterator iterator(int value) {
-        return new SIntListIterator(value);
-    }
-    
-    private static final class SIntList extends IntArrayList {
-
-        private final int value;
-
-        public SIntList(int value) {
-            this.value = value;
-        }
-
-        @Override
-        public IntListIterator iterator() {
-            return new SIntListIterator(value);
-        }
-        
-        @Override
-        public int size() {
-            return 1;
-        }
-
-        @Override
-        public boolean isEmpty() {
-            return false;
-        }
-
-        @Override
-        public boolean contains(int k) {
-            return value == k;
-        }
-
-        @Override
-        public int[] toIntArray(int[] target) {
-            int[] result = target;
-            if (result == null || result.length < 1) {
-               result = new int[1];
-            }
-            result[0] = value;
-            return result;
-        }
-
-        @Override
-        public int[] toIntArray() {
-            return new int[]{value};
-        }
-        
-        @Override
-        public IntList subList(int fromIndex, int toIndex) {
-            ArrayAllocator.ensureFromTo(1, fromIndex, toIndex);
-            return this;
-        }
-
-        
-    }
-
-    private static final class SIntListIterator implements IntListIterator {
-
-        private final int value;
-        private boolean ready;
-
-        public SIntListIterator(int value) {
-            this.value = value;
-            this.ready = true;
-        }
-
-        @Override
-        public boolean hasNext() {
-            return ready;
-        }
-        
-        @Override
-        public boolean hasPrevious() {
-            return !ready;
-        }
-
-        @Override
-        public int nextInt() {
-            if(!ready) {
-                throw new NoSuchElementException();
-            }
-            ready = false;
-            return value;
-        }
-
-        @Override
-        public int previousInt() {
-            if(ready) {
-                throw new NoSuchElementException();
-            }
-            ready = true;
-            return value;
-        }
-        
-        
-
-        @Override
-        public int nextIndex() {
-            return ready ? 0 : -1;
-        }
-
-        @Override
-        public int previousIndex() {
-            return ready ? -1 : 0;
-        }
-
-    }
-    
-}