All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mp4parser.tools.RangeStartMap Maven / Gradle / Ivy

Go to download

A generic parser and writer for all ISO 14496 based files (MP4, Quicktime, DCF, PDCF, ...)

There is a newer version: 1.9.56
Show newest version
package org.mp4parser.tools;

import java.util.*;

/**
 * Created by sannies on 10.09.2014.
 */
public class RangeStartMap implements Map {
    TreeMap base = new TreeMap(new Comparator() {
        public int compare(K o1, K o2) {
            return -o1.compareTo(o2);
        }
    });

    public RangeStartMap() {
    }

    public RangeStartMap(K k, V v) {
        this.put(k, v);
    }

    public int size() {
        return base.size();
    }

    public boolean isEmpty() {
        return base.isEmpty();
    }

    public boolean containsKey(Object key) {
        return base.get(key) != null;
    }

    public boolean containsValue(Object value) {
        return false;
    }

    public V get(Object k) {
        if (!(k instanceof Comparable)) {
            return null;
        }
        Comparable key = (Comparable) k;
        if (isEmpty()) {
            return null;
        }
        Iterator keys = base.keySet().iterator();
        K a = keys.next();
        do {
            if (keys.hasNext()) {
                if (key.compareTo(a) < 0) {
                    a = keys.next();
                } else {
                    return base.get(a);
                }
            } else {
                return base.get(a);
            }
        } while (true);
    }

    public V put(K key, V value) {
        return base.put(key, value);
    }

    public V remove(Object k) {
        if (!(k instanceof Comparable)) {
            return null;
        }
        Comparable key = (Comparable) k;
        if (isEmpty()) {
            return null;
        }
        Iterator keys = base.keySet().iterator();
        K a = keys.next();
        do {
            if (keys.hasNext()) {
                if (key.compareTo(a) < 0) {
                    a = keys.next();
                } else {
                    return base.remove(a);
                }
            } else {
                return base.remove(a);
            }
        } while (true);
    }


    public void putAll(Map m) {
        base.putAll(m);
    }


    public void clear() {
        base.clear();
    }


    public Set keySet() {
        return base.keySet();
    }


    public Collection values() {
        return base.values();
    }


    public Set> entrySet() {
        return base.entrySet();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy