Android Open Source - android-gskbyte-utils List Hash Map






From Project

Back to project page android-gskbyte-utils.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project android-gskbyte-utils listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.gskbyte.collection;
/* w ww . j av  a 2 s .c  o m*/
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * Allows some extra methods, just by implementing the abstract method keyForValue()
 * 
 * implements most methods from the List interface
 * */
public abstract class ListHashMap<K, V>
extends ArrayHashMap<K, V>
{
private static final long serialVersionUID = -8108026109763603119L;

public ListHashMap()
{ super(); }

public ListHashMap(int capacity)
{ super(capacity); }

public ListHashMap(int capacity, float loadFactor)
{ super(capacity, loadFactor); }

public ListHashMap(Map<K,V> map)
{ super(map); }

/**
 * The star method 
 * */
protected abstract K keyForValue(V value);

public V put(V value)
{ return super.put(keyForValue(value), value); }

// List-like methods

public boolean add(V value)
{ return add(keyForValue(value), value); }

public boolean add(int index, V value)
{ return add(index, keyForValue(value), value); }

public int indexOf(V value)
{ return unmodifiableKeyList().indexOf(keyForValue(value)); }


//true if list changes, false if not
public boolean addAll(List<V> values)
{
    boolean appendsSomething = false;
    for(V v : values) {
        if( add(v) ) {
            appendsSomething = true;
        }
    }
    
    return appendsSomething;
}

//true if list changed
public boolean removeAll(Collection<V> values)
{
    boolean changed = false;
    for(V v : values) {
        K key = keyForValue(v);
        if( this.remove(key) != null)
            changed = true;
    }
    return changed;
}

//true if list changed
public boolean retainAll(Collection<V> values)
{
    boolean changed = false;
    for(V externalValue : values) {
        K keyForExternal = keyForValue(externalValue);
        if(!containsKey(keyForExternal)) {
            remove(keyForExternal);
            changed = true;
        }
    }
    return changed;
}

public boolean containsAllValues(Collection<? extends V> values)
{
    for(V v : values) {
        if(!containsValue(v))
            return false;
    }
    return true;
}
@SuppressWarnings("unchecked")
@Override
public boolean containsValue(Object value)
{
    return containsKey( keyForValue((V)value) );
}


}




Java Source Code List

com.woozzu.android.widget.IndexScroller.java
com.woozzu.android.widget.IndexableListView.java
org.gskbyte.FragmentWrapperActivity.java
org.gskbyte.animation.ExpandAnimation.java
org.gskbyte.bitmap.AbstractBitmapManager.java
org.gskbyte.bitmap.BitmapColorizer.java
org.gskbyte.bitmap.BitmapManager.java
org.gskbyte.bitmap.CachedBitmapColorizer.java
org.gskbyte.bitmap.IndexedBitmaps.java
org.gskbyte.bitmap.LRUBitmapCache.java
org.gskbyte.bitmap.LRUBitmapManager.java
org.gskbyte.bitmap.PrivateBitmapManager.java
org.gskbyte.bitmap.ReferencedBitmaps.java
org.gskbyte.collection.ArrayHashMap.java
org.gskbyte.collection.DoubleSparseArray.java
org.gskbyte.collection.ListHashMap.java
org.gskbyte.dialog.DownloadDialogFragment.java
org.gskbyte.dialog.LoadDialogFragment.java
org.gskbyte.dialog.OpenLinkDialogBuilder.java
org.gskbyte.dialog.PickerDialogFragment.java
org.gskbyte.download.DiskDownload.java
org.gskbyte.download.DownloadManager.java
org.gskbyte.download.Download.java
org.gskbyte.download.MemoryDownload.java
org.gskbyte.drawable.AutoBackgroundButtonDrawable.java
org.gskbyte.listener.IListenable.java
org.gskbyte.listener.ListenableNG.java
org.gskbyte.listener.Listenable.java
org.gskbyte.preferences.DialogSeekBarPreference.java
org.gskbyte.preferences.InlineSeekBarPreference.java
org.gskbyte.remote.AsyncURLRequest.java
org.gskbyte.remote.URLRequest.java
org.gskbyte.tasks.QueuedTaskExecutor.java
org.gskbyte.tasks.TaskStep.java
org.gskbyte.tasks.Task.java
org.gskbyte.ui.ArrayAdapterWithDefaultValue.java
org.gskbyte.ui.ListAdapter.java
org.gskbyte.ui.ColorDialog.ColorDialog.java
org.gskbyte.ui.ColorDialog.ColorPreference.java
org.gskbyte.ui.iconifiedMainMenuList.EntryView.java
org.gskbyte.ui.iconifiedMainMenuList.MainMenuAdapter.java
org.gskbyte.ui.iconifiedMainMenuList.MenuEntry.java
org.gskbyte.util.FrequentIntents.java
org.gskbyte.util.IOUtils.java
org.gskbyte.util.Logger.java
org.gskbyte.util.OpenFileHandlerFactory.java
org.gskbyte.util.OpenFileHandler.java
org.gskbyte.util.XmlUtils.java
org.gskbyte.view.AsyncImageView.java
org.gskbyte.view.AutoBackgroundButton.java
org.gskbyte.view.AutoBackgroundImageButton.java
org.gskbyte.view.AutoHeightImageView.java
org.gskbyte.view.ExpandedGridView.java
org.gskbyte.view.ExpandedListView.java
org.gskbyte.view.FontUtil.java
org.gskbyte.view.FontableButton.java
org.gskbyte.view.FontableCheckBox.java
org.gskbyte.view.FontableEditText.java
org.gskbyte.view.FontableTextView.java
org.gskbyte.view.FullWidthImageView.java
org.gskbyte.view.ProportionalHeightLayout.java
org.gskbyte.view.PullToRefreshListView.java
org.gskbyte.view.SquaredLayout.java
org.gskbyte.view.StepSeekBar.java
org.gskbyte.view.TextViewUtil.java
org.gskbyte.view.ViewUtils.java