<commit_before>/* 
 * Class for handling linked lists. 
 * By <NAME> Copyright � 2007
 * 
 * License: This code is licensed under the terms of the "New BSD License"
 * http://creativecommons.org/licenses/BSD/
 */

#ifndef __JCOM_LIST_H_
#define __JCOM_LIST_H__

#include <list>
using namespace std;

/** A template class for managing linked lists */
template<class T> 
class jcomList {
public:
	
	jcomList() { };
	jcomList(const T& rhs) // copy constructor
	{ ll.insert(ll.begin(), rhs.begin(), rhs.end()); }
	
	~jcomList() { };
		
	typedef typename list<T>::iterator jcomListIterator;

	/** Put an item at the front of the list
	 * @param x the item to add to the list
	*/
	void push_front(const T& x) 
	{ ll.push_front(x); }
	/** Put an item at the back of the list
	 * @param x the item to add to the list
	*/
	void push_back(const T& x)
	{ ll.push_back(x); }
	
	/** Remove an item from the list if it exists.
	 * @param x the item in the list 
	*/
	void remove(const T& x)
	{
		jcomListIterator i = find(ll.begin(), ll.end(), x);
		if (i != ll.end())
			ll.erase(i);
	}
	
	bool find(const T& x) 
	{
		return find(ll.begin(), ll.end(), x) != ll.end();
	}
	template<typename Predicate>
	T& find_if (jcomListIterator first, jcomListIterator last, Predicate pred)
	{
		jcomListIterator result;
		while (first != last) {
			result = pred(first, last);
			++first;
		}
		return result != ll.end() ? result : NULL;
	}
	
	T& element(const T& x) 
	{
		jcomListIterator i = find(ll.begin(), ll.end(), x);
		return *i;
	}
	
	/** Merges a new item into the list sorting it according to the function object comp
	 * @param x the new item to merge
	 * @param comp A function object to determine where in the list the new item should
	 * be placed
	*/
	template<typename Compare>
	void merge(const T& x, Compare comp)
	{
		list<T> m;
		m.push_front(x);
		ll.merge(m, comp);
	}
	/** @return the number of elements in the list */	
	long size() { return (long)ll.size(); }
	/** @return true if the list is empty, false otherwise */
	bool empty() const { return ll.empty(); }
	/** Removes the list item at position.  
	 * @param position the position of the list item to remove
	 * @return an updated iterator pointing to the position that followed the removed item
	 */
	jcomListIterator erase(jcomListIterator position) { return ll.erase(position); }
	/** Removes the list item at position.  
	 * @param position the position of the list item to remove
	 */
	void remove(jcomListIterator position) { ll.erase(position); }
	/** @return an iterator to the front of the list */
	jcomListIterator begin() { return ll.begin(); }
	/** @return an iterator to one past the end of the list */
	jcomListIterator end() { return ll.end(); }
	/** Removes all list items */
	void clear() { ll.clear(); }
	
private:
	list<T> ll;
<commit_msg>Adding and editing doxygen comments in jcom.list.h of the Modular library.<commit_after>/* 
 * Class for handling linked lists. 
 * By <NAME> Copyright � 2007
 * 
 * License: This code is licensed under the terms of the "New BSD License"
 * http://creativecommons.org/licenses/BSD/
 */

#ifndef __JCOM_LIST_H_
#define __JCOM_LIST_H__

#include <list>
using namespace std;

/** A template class for managing linked lists. */
template<class T> 
class jcomList {

public:
	
	/** Class constructor. */
	jcomList() { };

	jcomList(const T& rhs) // copy constructor
	{ ll.insert(ll.begin(), rhs.begin(), rhs.end()); }
	
	/** Class destructor. */
	~jcomList() { };
		
	typedef typename list<T>::iterator jcomListIterator;

	/** Put an item at the front of the list.
	 * @param x		The item to add to the list
	*/
	void push_front(const T& x) 
	{ ll.push_front(x); }

	/** Put an item at the back of the list.
	 * @param x		The item to add to the list
	*/
	void push_back(const T& x)
	{ ll.push_back(x); }
	
	/** Remove an item from the list if it exists.
	 * @param x		The item in the list.
	*/
	void remove(const T& x)
	{
		jcomListIterator i = find(ll.begin(), ll.end(), x);
		if (i != ll.end())
			ll.erase(i);
	}
	
	/** Test to see if an item is member of the list.
	 @param x		The item to search for.
	 @return		true if the item is found, else false.
	 */
	bool find(const T& x) 
	{
		return find(ll.begin(), ll.end(), x) != ll.end();
	}
	template<typename Predicate>
	T& find_if (jcomListIterator first, jcomListIterator last, Predicate pred)
	{
		jcomListIterator result;
		while (first != last) {
			result = pred(first, last);
			++first;
		}
		return result != ll.end() ? result : NULL;
	}
	
	T& element(const T& x) 
	{
		jcomListIterator i = find(ll.begin(), ll.end(), x);
		return *i;
	}
	
	/** Merges a new item into the list sorting it according to the function object comp
	 * @param x the new item to merge
	 * @param comp A function object to determine where in the list the new item should
	 * be placed
	*/
	template<typename Compare>
	void merge(const T& x, Compare comp)
	{
		list<T> m;
		m.push_front(x);
		ll.merge(m, comp);
	}
	
	/**  Get the number of elements in the list.
	 @return		The number of elements in the list */	
	long size() { return (long)ll.size(); }
	
	/** Check if the list is empty.
	 @return		True if the list is empty, false otherwise */
	bool empty() const { return ll.empty(); }
	
	/** Remove the list item at given position.  
	 * @param		Position the position of the list item to remove.
	 * @return		An updated iterator pointing to the position that followed the removed item.
	 */
	jcomListIterator erase(jcomListIterator position) { return ll.erase(position); }

	/**	Remove the list item at a given position.
	 * @param position The position of the list item to remove.
	 */
	void remove(jcomListIterator position) { ll.erase(position); }
	
	/** Iterate to the front of the list.
	 @return		An iterator to the front of the list. */
	jcomListIterator begin() { return ll.begin(); }
	
	/** Iterate to one past the end of the list.
	 @return		An iterator to one past the end of the list. */
	jcomListIterator end() { return ll.end(); }
	
	/** Removes all list items. */
	void clear() { ll.clear(); }
	
private:
	list<T> ll;

{'fraction_non_alphanumeric': 0.12504113195129976, 'fraction_numerical': 0.0013162224415926291, 'mean_word_length': 3.2362369337979096, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '6787492', 'n_tokens_mistral': 2116, 'n_tokens_neox': 1973, 'n_words': 772}