<commit_before>package org.jgroups.util;


/**
 * A bounded subclass of List, oldest elements are removed once max capacity is exceeded
 * @author <NAME> Nov 20, 2003
 * @version $Id: BoundedList.java,v 1.1 2003/11/21 06:54:50 belaban Exp $
 */
public class BoundedList extends List {
    int max_capacity=10;


    public BoundedList(int size) {
        super();
        max_capacity=size;
    }

    /**
     * Adds an element at the tail. Removes an object from the head if capacity is exceeded
     * @param obj The object to be added
     */
    public void add(Object obj) {
        if(obj == null) return;
        while(size >= max_capacity && size > 0) {
            removeFromHead();
        }
        super.add(obj);
    }


    /**
     * Adds an object to the head, removes an element from the tail if capacity has been exceeded
     * @param obj The object to be added
     */
    public void addAtHead(Object obj) {
        if(obj == null) return;
        while(size >= max_capacity && size > 0) {
            remove();
        }
        super.addAtHead(obj);
    }
}
<commit_msg>no message<commit_after>package org.jgroups.util;


/**
 * A bounded subclass of List, oldest elements are removed once max capacity is exceeded
 * @author <NAME> 20, 2003
 * @version $Id: BoundedList.java,v 1.2 2004/07/26 15:23:26 belaban Exp $
 */
public class BoundedList extends List {
    int max_capacity=10;



    public BoundedList() {
    }

    public BoundedList(int size) {
        super();
        max_capacity=size;
    }


    /**
     * Adds an element at the tail. Removes an object from the head if capacity is exceeded
     * @param obj The object to be added
     */
    public void add(Object obj) {
        if(obj == null) return;
        while(size >= max_capacity && size > 0) {
            removeFromHead();
        }
        super.add(obj);
    }


    /**
     * Adds an object to the head, removes an element from the tail if capacity has been exceeded
     * @param obj The object to be added
     */
    public void addAtHead(Object obj) {
        if(obj == null) return;
        while(size >= max_capacity && size > 0) {
            remove();
        }
        super.addAtHead(obj);
    }
}

{'fraction_non_alphanumeric': 0.10004426737494466, 'fraction_numerical': 0.023019034971226208, 'mean_word_length': 2.0294906166219837, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4025887', 'n_tokens_mistral': 732, 'n_tokens_neox': 650, 'n_words': 230}