<commit_before>// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
// vim: ts=8 sw=2 smarttab
/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2004-2006 <NAME> <<EMAIL>>
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software 
 * Foundation.  See file COPYING.
 * 
 */

#ifndef __XLIST_H
#define __XLIST_H

template<typename T>
class xlist {
public:
  struct item {
    T _item;
    item *_prev, *_next;
    xlist *_head;
    
    item(T i) : _item(i), _prev(0), _next(0), _head(0) {}
    ~item() { 
      remove_myself();
    }
    
    xlist* get_xlist() { return _head; }
    void remove_myself() {
      if (_head) 
	_head->remove(this);
      assert(_head == 0);
    }
  };

private:
  item *_front, *_back;
  int _size;

public:
  xlist() : _front(0), _back(0), _size(0) {}

  int size() { return _size; }
  bool empty() { 
    assert((bool)_front == (bool)_size);
    return _front == 0; 
  }

  void clear() {
    while (_front) remove(_front);
  }

  void push_back(item *item) {
    if (item->_head) 
      item->_head->remove(item);

    item->_head = this;
    item->_next = 0;<commit_msg>verify xlist empty in destructor<commit_after>// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
// vim: ts=8 sw=2 smarttab
/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2004-2006 <NAME> <<EMAIL>.net>
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software 
 * Foundation.  See file COPYING.
 * 
 */

#ifndef __XLIST_H
#define __XLIST_H

template<typename T>
class xlist {
public:
  struct item {
    T _item;
    item *_prev, *_next;
    xlist *_head;
    
    item(T i) : _item(i), _prev(0), _next(0), _head(0) {}
    ~item() { 
      remove_myself();
    }
    
    xlist* get_xlist() { return _head; }
    void remove_myself() {
      if (_head) 
	_head->remove(this);
      assert(_head == 0);
    }
  };

private:
  item *_front, *_back;
  int _size;

public:
  xlist() : _front(0), _back(0), _size(0) {}
  ~xlist() { 
    assert(_size == 0);
    assert(_front == 0);
    assert(_back == 0);
  }

  int size() { return _size; }
  bool empty() { 
    assert((bool)_front == (bool)_size);
    return _front == 0; 
  }

  void clear() {
    while (_front) remove(_front);
  }

  void push_back(item *item) {
    if (item->_head) 
      item->_head->remove(item);

    item->_head = this;
    item->_next = 0;
{'fraction_non_alphanumeric': 0.15504169825625475, 'fraction_numerical': 0.018574677786201668, 'mean_word_length': 2.732673267326733, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '7299172', 'n_tokens_mistral': 1001, 'n_tokens_neox': 939, 'n_words': 262}