Ignore:
Timestamp:
Apr 15, 2017, 7:09:59 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
c57d1935
Parents:
308880c
Message:

Minor cleanup, also filled in benchmark source appendix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/generic_types/evaluation/cpp-vstack.cpp

    r308880c ra381b46  
    11#include "cpp-vstack.hpp"
    2 
    32#include <utility>
    43
    54stack::node::node( const object& v ) : value( v.new_copy() ), next( nullptr ) {}
    6 
    75stack::node::node( ptr<object>&& v, node* n ) : value( std::move(v) ), next( n ) {}
    86
     
    1816}
    1917
    20 void stack::clear() {
    21         node* next = head;
    22         while ( next ) {
    23                 node* crnt = next;
    24                 next = crnt->next;
    25                 delete crnt;
    26         }
    27         head = nullptr;
    28 }
    29 
    3018stack::stack() : head(nullptr) {}
    31 
    3219stack::stack(const stack& o) { copy(o); }
    33 
    3420stack::stack(stack&& o) : head(o.head) { o.head = nullptr; }
    35 
    3621stack::~stack() { clear(); }
    3722
     
    5035}
    5136
     37void stack::clear() {
     38        node* next = head;
     39        while ( next ) {
     40                node* crnt = next;
     41                next = crnt->next;
     42                delete crnt;
     43        }
     44        head = nullptr;
     45}
     46
     47
    5248bool stack::empty() const { return head == nullptr; }
    5349
Note: See TracChangeset for help on using the changeset viewer.