<commit_before>//
// This file is part of the OpenNMS(R) Application.
//
// OpenNMS(R) is Copyright (C) 2005 The OpenNMS Group, Inc.  All rights reserved.
// OpenNMS(R) is a derivative work, containing both original code, included code and modified
// code that was published under the GNU General Public License. Copyrights for modified 
// and included code are below.
//
// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
//
// Modifications:
//
// 2007 Jul 14: Use Java 5 generics and indent. - <EMAIL>
//
// Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// For more information contact:
// OpenNMS Licensing       <<EMAIL>>
//     http://www.opennms.org/
//     http://www.opennms.com/
//
package org.opennms.netmgt.config;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

// TODO make this implement Collection
public class TimeIntervalSequence {
    
    private static class TimeIntervalSeqIter implements Iterator<TimeInterval> {

        private TimeIntervalSequence m_current;
        
        public TimeIntervalSeqIter(TimeIntervalSequence seq) {
            m_current = seq;
        }

        public boolean hasNext() {
            return m_current != null && m_current.m_interval != null;
        }

        public TimeInterval next() {
            TimeInterval interval = m_current.m_interval;
            m_current = m_current.m_tail;
            return interval;
        }

        public void remove() {
            throw new UnsupportedOperationException("not implemented yet");
        }

    }

    private TimeInterval m_interval;
    private TimeIntervalSequence m_tail;
    
    public TimeIntervalSequence() {
        this(null, null);
    }

    public TimeIntervalSequence(TimeInterval interval) {
        this(interval, null);
    }
    
    private TimeIntervalSequence(TimeInterval interval, TimeIntervalSequence tail) {
        m_interval = interval;
        m_tail = tail;
    }
    
    public Iterator iterator() {
        return new TimeIntervalSeqIter(this);
    }
    
    Date min(Date a, Date b) {
       return (a.before(b) ? a : b); 
    }
    
    Date max(Date a, Date b) {
        return (b.before(a) ? a: b);
    }

    public void addInterval(TimeInterval interval) {
        if (m_interval == null) {<commit_msg>Oops... need to make sure that iterator() returns Iterator<TimeInterval>.<commit_after>//
// This file is part of the OpenNMS(R) Application.
//
// OpenNMS(R) is Copyright (C) 2005 The OpenNMS Group, Inc.  All rights reserved.
// OpenNMS(R) is a derivative work, containing both original code, included code and modified
// code that was published under the GNU General Public License. Copyrights for modified 
// and included code are below.
//
// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
//
// Modifications:
//
// 2007 Jul 14: Use Java 5 generics and indent. - <EMAIL>
//
// Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// For more information contact:
// OpenNMS Licensing       <<EMAIL>>
//     http://www.opennms.org/
//     http://www.opennms.com/
//
package org.opennms.netmgt.config;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

// TODO make this implement Collection
public class TimeIntervalSequence {
    
    private static class TimeIntervalSeqIter implements Iterator<TimeInterval> {

        private TimeIntervalSequence m_current;
        
        public TimeIntervalSeqIter(TimeIntervalSequence seq) {
            m_current = seq;
        }

        public boolean hasNext() {
            return m_current != null && m_current.m_interval != null;
        }

        public TimeInterval next() {
            TimeInterval interval = m_current.m_interval;
            m_current = m_current.m_tail;
            return interval;
        }

        public void remove() {
            throw new UnsupportedOperationException("not implemented yet");
        }

    }

    private TimeInterval m_interval;
    private TimeIntervalSequence m_tail;
    
    public TimeIntervalSequence() {
        this(null, null);
    }

    public TimeIntervalSequence(TimeInterval interval) {
        this(interval, null);
    }
    
    private TimeIntervalSequence(TimeInterval interval, TimeIntervalSequence tail) {
        m_interval = interval;
        m_tail = tail;
    }
    
    public Iterator<TimeInterval> iterator() {
        return new TimeIntervalSeqIter(this);
    }
    
    Date min(Date a, Date b) {
       return (a.before(b) ? a : b); 
    }
    
    Date max(Date a, Date b) {
        return (b.before(a) ? a: b);
    }

    public void addInterval(TimeInterval interval) {
        if (m_interval == null) {
{'fraction_non_alphanumeric': 0.08923467767545253, 'fraction_numerical': 0.010797078437599238, 'mean_word_length': 2.6515942028985506, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5110548', 'n_tokens_mistral': 1765, 'n_tokens_neox': 1682, 'n_words': 650}