| 714 | } |
| 715 | |
| 716 | forceinline int |
| 717 | StatePool::state(StatePoolAllocator& spm, PosSet* ps) { |
| 718 | int d = 0; |
| 719 | StateNode** p = nullptr; |
| 720 | StateNode* n = &root; |
| 721 | do { |
| 722 | switch (PosSet::cmp(ps,n->pos)) { |
| 723 | case PSC_EQ: return n->state; |
| 724 | case PSC_LE: p = &n->left; n = *p; break; |
| 725 | case PSC_GR: p = &n->right; n = *p; break; |
| 726 | default: GECODE_NEVER; |
| 727 | } |
| 728 | d++; |
| 729 | } while (n != nullptr); |
| 730 | n = new (spm) StateNode; *p = n; |
| 731 | n->pos = ps; |
| 732 | n->state = n_states++; |
| 733 | n->next = next; |
| 734 | n->left = nullptr; |
| 735 | n->right = nullptr; |
| 736 | next = n; |
| 737 | return n->state; |
| 738 | } |
| 739 | |
| 740 | /** |
| 741 | * \brief Sort symbols |