A Nice C++ Linked List

I had reason to brush up on my C/C++ skills a bit and did something I've wanted to do for some time: implemented a nice encapsulated linked list. Read more for the source.

#include <iostream>
#include <stdarg.h>

typedef unsigned char boolean;

class LinkedList {
  
  private:
    LinkedList *m_start, *m_curr, *m_next;
    int m_data;
  
  public:    
    /*Constructors*/
    LinkedList();
    LinkedList(LinkedList* );
    
    /*Operations*/
    void insert(int);   
    void insertMultiple(int count, ...);  
    int getData();
    int getDataEl();
    void setData(int);
    LinkedList* getNext();
    void setNext(LinkedList* );

    
    /*Movement*/
    void start();
    void next();
    void end();        
    void reset();
    
    /*Boolean*/
    boolean isEnd();
    boolean isEmpty();
    
};


LinkedList::LinkedList() {
  m_curr = m_start = this;
  m_next = NULL;
}

LinkedList::LinkedList(LinkedList* start) {
  m_start = start;
  m_next = NULL;
}

void LinkedList::insert(int el) {
  m_curr->setData(el);
  m_curr->setNext(new LinkedList(m_start)); 
  m_curr = m_curr->getNext(); 
}

void LinkedList::insertMultiple(int count, ...) {
  va_list ap;
  va_start(ap, count);
  while(count--)     
    insert(va_arg(ap, int)); 
  va_end(ap);
}

int LinkedList::getDataEl() {
  return m_data;
}

int LinkedList::getData() {
  return m_curr->getDataEl();
}

void LinkedList::setData(int el) {
  m_data = el;
}

LinkedList* LinkedList::getNext() {
  return m_next;
}

void LinkedList::setNext(LinkedList* link) {
  m_next = link;
}

void LinkedList::next() {
  m_curr = m_curr->getNext();
}

boolean LinkedList::isEnd() {
  return m_curr->getNext() == NULL ? 1 : 0;
}

void LinkedList::reset() {
  m_curr = m_start;
}

int main() {
  LinkedList l;
  l.insertMultiple(3, 5, 6, 7); 
  for(l.reset(); !l.isEnd(); l.next()) 
    std::cout << l.getData();
    
  return 0;
}
Here's a doubly linked list version:


#include <iostream>
#include <stdarg.h>

typedef unsigned char boolean;

class LinkedList {
  
  private:
    LinkedList *m_curr, *m_next, *m_prev;
    int m_data;
  
  public:    
    /*Constructors*/
    LinkedList();
    LinkedList(LinkedList* );
    
    /*Operations*/
    void insert(int);   
    void insertMultiple(int count, ...);  

    /*Get Setters*/
    int getData();
    int getDataEl();
    void setData(int);
    LinkedList* getPrev();
    LinkedList* getNext();
    void setNext(LinkedList* );        
    
    /*Movement*/
    void reset();
    void prev();
    void next();
    void end();           
    
    /*Boolean*/
    boolean isBeginning();
    boolean isEnd();
    boolean isEmpty();
    
};


LinkedList::LinkedList() {
  m_curr = this;
  m_prev = NULL;
  m_next = NULL;
}

LinkedList::LinkedList(LinkedList* prev) {
  m_prev = prev;
  m_next = NULL;
}

void LinkedList::insert(int el) {
  while (m_curr->getNext() != NULL)
    m_curr = m_curr->getNext();
  m_curr->setData(el);
  m_curr->setNext(new LinkedList(m_curr));
}

void LinkedList::insertMultiple(int count, ...) {
  va_list ap;
  va_start(ap, count);
  while(count--)     
    insert(va_arg(ap, int)); 
  va_end(ap);
}

int LinkedList::getDataEl() {
  return m_data;
}

int LinkedList::getData() {
  return m_curr->getDataEl();
}

void LinkedList::setData(int el) {
  m_data = el;
}

LinkedList* LinkedList::getPrev() {
  return m_prev;
}

LinkedList* LinkedList::getNext() {
  return m_next;
}

void LinkedList::setNext(LinkedList* link) {
  m_next = link;
}

void LinkedList::reset() {
  m_curr = this;
}

void LinkedList::next() {
  m_curr = m_curr->getNext();
}

void LinkedList::prev() {
  m_curr = m_curr->getPrev();
}

boolean LinkedList::isEnd() {
  return m_curr->getNext() == NULL ? 1 : 0;
}

boolean LinkedList::isBeginning() {
  return m_curr == NULL ? 1 : 0;
}

boolean LinkedList::isEmpty() {
  return m_curr->getNext() == m_curr->getPrev() ? 1 : 0;
}

int main() {
  LinkedList l;
  l.insertMultiple(4, 5, 6, 7, 8); 

  for(; !l.isBeginning(); l.prev())
    std::cout << l.getData();
   
  return 0;
}

Submitted by Drugan888 on Wed, 2008-10-01 15:09.
free porn pics free teen porn pics free gay porn pics free porn sites best free porn sites free porn video sites free gay porn sites free teen porn free teen porn videos free teen porn movies free teen porn pics free teen porn clips free young teen porn teen porn free free teen lesbian porn free teen porn video free teen porn vids free streaming porn free porn streaming streaming free porn free streaming porn videos streaming porn free free streaming porn clips free amateur porn free amateur porn videos free amateur porn video free amateur porn movies free porn vids free long porn vids free teen porn vids free full porn vids free amature porn vids anime porn vids for free free streaming porn vids free full length porn vids free cartoon porn free cartoon porn videos free 3d cartoon porn cartoon porn free free cartoon porn movies free cartoon porn games free cartoon porn video cartoon porn that i can watch for free free famous cartoon porn free cartoon porn clips free porn games free online porn games free anime porn games free cartoon porn games free flash porn games free porn flash games free adult porn games free hentai porn games free online anime porn games free online porn free porn online free online porn games free online porn videos free online porn movies free online porn clips watch free porn online free porn videos online free online beasteality porn free porn movies online free online lesbian porn free online gay porn free porn movie online free hardcore porn free hardcore porn videos free hardcore porn movies free hardcore porn pic hunter hardcore free porn hardcore porn free free hardcore porn pics