GNU   davin.50webs.com/research
Bringing to you notes for the ages

       Main Menu          Research Projects         Photo Album            Curriculum Vitae      The Greatest Artists
    Email Address       Computer Games          Web Design          Java Training Wheels      The Fly (A Story)   
  Political Activism   Scruff the Cat       My Life Story          Smoking Cessation          Other Links      
Debugging Macros     String Class I     Linked List System I Java for C Programmers Naming Convention
    String Class II         How I use m4              Strings III                 Symmetrical I/O             Linked Lists II     
Run-Time Type Info   Virtual Methods      An Array System        Science & Religion            Submodes       
  Nested Packages      Memory Leaks    Garbage Collection      Internet & Poverty      What is Knowledge?
Limits of Evolution   Emacs Additions      Function Plotter           Romantic Love        The Next Big Thing
    Science Fiction     Faster Compilation Theory of Morality         Elisp Scoping               Elisp Advice      
  S.O.G.M. Pattern       Safe Properties         School Bullying          Charisma Control          Life and Death    
     Splitting Java          Multiple Ctors       Religious Beliefs         Conversation 1           Conversation 2    
   J.T.W. Language    Emacs Additions II      Build Counter             Relation Plotter          Lisp++ Language  
  Memory Leaks II   Super Constructors CRUD Implementation Order a Website Form There Is An Afterlife
More Occam's Razor C to Java Translator Theory of Morality II


class List_Extra<X>

public:

These functions are used for converting Nodes (efficient O(1)
access) to indices (inefficient O(n) access) and vice-versa.
Functions get_index and get_element_at are inverses of each other.
Note that indices start from zero, like C/C++/Java arrays.

Examples of inverse property: Variables n is a Node<X>* and i is an int

    get_element_at(n->get_owner(),get_index(n)) == n.
    get_index(get_element_at(list,i))           == i

Returns the index of a given node.

   friend int get_index(const Node<X>* node)


Returns the node of a given index.

   friend Node<X>* get_element_at(List<X>* list, int index)


Returns the const node of a given index.

   friend Node<X>* get_element_at_const(const List<X>* list, int index)


These functions internally call get_element_at function.

   friend void set_element_at(List<X>* list, int index, X* x)
   friend void set_element_at(List<X>* list, int index, Node<X>* node)



Find functions.  Each function takes O(n) time.

Finds the first node matching element in the sense of operator == (const X*, const X*)
searching forward from start.

   friend Node<X>* find_element_eq(Node<X>* start, const X* element)

Const version of the above function.

   friend const Node<X>* find_element_eq_const(const Node<X>* start, const X* element)


Creates a shallow clone of list.  Takes O(n) time.
   friend List<X>* clone_shallow(List<X>* list)


Deletes duplicates in the sense of operator == (void*, void*).  Takes O(n^2) time.
   friend void delete_duplicates_eq(List<X>* list)


Does a quicksort of the given list.
   friend void quicksort(List<X>* list,   bool is_le(X* x1, X* x2))


Inessential List functions.  Each function takes O(1) time.

Abbreviation for: (list->get_length() == 0)
   bool                  is_empty(List<X>* list);

Convenient methods for efficiently accessing second, third, second to last and
third to last elements of list.  Assertion fails if no such element exists.
   friend Node<X>*       get_second(List<X>* list)
   friend Node<X>*       get_third(List<X>* list)
   friend Node<X>*       get_second_to_last(List<X>* list)
   friend Node<X>*       get_third_to_last(List<X>* list)

Const versions of the above functions.
   friend const Node<X>* get_second_const(const List<X>* list)
   friend const Node<X>* get_third_const(const List<X>* list)
   friend const Node<X>* get_second_to_last_const(const List<X>* list)
   friend const Node<X>* get_third_to_last_const(const List<X>* list)


Inessential Node functions.  Each function takes O(1) time.

Abbreviation for (node->get_previous_const() == null)
   friend bool           is_first(const Node<X>* node)
Abbreviation for (node->get_next_const() == null)
   friend bool           is_last(const Node<X>* node)

Abbreviation for
((node->get_next() != null) ? node->get_next() : node->get_owner()->get_first())
   friend Node<X>*       cyclic_next(Node<X>* node);

Abbreviation for
((node->get_previous() != null) ? node->get_previous() : node->get_owner()->get_last())
   friend Node<X>*       cyclic_previous(Node<X>* node);

Const versions of the above functions.
   friend const Node<X>* cyclic_next_const(const Node<X>* node);
   friend const Node<X>* cyclic_previous_const(const Node<X>* node);


Back to Linked List System II
| Main Menu | Research Projects | Photo Album | Curriculum Vitae | The Greatest Artists |
| Email Address | Computer Games | Web Design | Java Training Wheels | The Fly (A Story) |
| Political Activism | Scruff the Cat | My Life Story | Smoking Cessation | Other Links |
| Debugging Macros | String Class I | Linked List System I | Java for C Programmers | Naming Convention |
| String Class II | How I use m4 | Strings III | Symmetrical I/O | Linked Lists II |
| Run-Time Type Info | Virtual Methods | An Array System | Science & Religion | Submodes |
| Nested Packages | Memory Leaks | Garbage Collection | Internet & Poverty | What is Knowledge? |
| Limits of Evolution | Emacs Additions | Function Plotter | Romantic Love | The Next Big Thing |
| Science Fiction | Faster Compilation | Theory of Morality | Elisp Scoping | Elisp Advice |
| S.O.G.M. Pattern | Safe Properties | School Bullying | Charisma Control | Life and Death |
| Splitting Java | Multiple Ctors | Religious Beliefs | Conversation 1 | Conversation 2 |
| J.T.W. Language | Emacs Additions II | Build Counter | Relation Plotter | Lisp++ Language |
| Memory Leaks II | Super Constructors | CRUD Implementation | Order a Website Form | There Is An Afterlife |
| More Occam's Razor | C to Java Translator | Theory of Morality II
Last modified: Sun Sep 25 16:11:42 NZDT 2016
Best viewed at 800x600 or above resolution.
© Copyright 1999-2016 Davin Pearson.
Please report any broken links to