static void swap_nodes(const node_ptr &this_node, const node_ptr &other_node) { if (other_node == this_node) return; bool this_inited = inited(this_node); bool other_inited = inited(other_node); if(this_inited){ init_header(this_node); } if(other_inited){ init_header(other_node); } node_ptr next_this(NodeTraits::get_next(this_node)); node_ptr prev_this(NodeTraits::get_previous(this_node)); node_ptr next_other(NodeTraits::get_next(other_node)); node_ptr prev_other(NodeTraits::get_previous(other_node)); //these first two swaps must happen before the other two swap_prev(next_this, next_other); swap_next(prev_this, prev_other); swap_next(this_node, other_node); swap_prev(this_node, other_node); if(this_inited){ init(other_node); } if(other_inited){ init(this_node); } }
Token Tokenizer::next() { switch( GetCharClass(*text) ) { case Char_Digit : return next_number(); case Char_Letter : return next_word(); case Char_Punct : return next_punct(); case Char_Space : return next_space(); case Char_Other : return next_other(); } return Token(); }