Lines Matching refs:state
44 // This is a VectorFstBaseImpl container that holds a State similar to
50 // final weight even if the state is non-final to mark it as
65 typedef S State;
89 // Gets a state from its ID; state must exist.
97 // Gets a state from its ID; state must exist.
105 // Gets a state from its ID; return 0 if it doesn't exist.
115 // Gets a state from its ID; add it if necessary.
118 return cache_first_state_; // Return 1st cached state
120 cache_first_state_id_ = s; // Remember 1st cached state
125 cache_first_state_id_ = s; // Reuse 1st cached state
127 return cache_first_state_; // Return 1st cached state
129 while (NumStates() <= s) // Add state to main cache
133 if (cache_first_state_id_ != kNoStateId) { // Forget 1st cached state
165 S *state = ExtendState(s);
166 state->final = w;
167 state->flags |= kCacheFinal | kCacheRecent;
171 S *state = ExtendState(s);
172 state->arcs.push_back(arc);
175 // Marks arcs of state s as cached.
177 S *state = ExtendState(s);
178 vector<Arc> &arcs = state->arcs;
179 state->niepsilons = state->noepsilons = 0;
185 ++state->niepsilons;
187 ++state->noepsilons;
190 state->flags |= kCacheArcs | kCacheRecent;
199 S *state = ExtendState(s);
200 state->arcs.reserve(n);
203 // Is the start state cached?
205 // Is the final weight of state s cached?
208 const S *state = CheckState(s);
209 if (state && state->flags & kCacheFinal) {
210 state->flags |= kCacheRecent;
217 // Are arcs of state s cached?
219 const S *state = CheckState(s);
220 if (state && state->flags & kCacheArcs) {
221 state->flags |= kCacheRecent;
229 const S *state = GetState(s);
230 return state->final;
234 const S *state = GetState(s);
235 return state->arcs.size();
239 const S *state = GetState(s);
240 return state->niepsilons;
244 const S *state = GetState(s);
245 return state->noepsilons;
250 const S *state = GetState(s);
252 data->narcs = state->arcs.size();
253 data->arcs = data->narcs > 0 ? &(state->arcs[0]) : 0;
254 data->ref_count = &(state->ref_count);
260 // Find the mininum never-expanded state Id
285 S* state = VectorFstBaseImpl<S>::GetState(s);
286 if (cache_size_ > cache_target && state->ref_count == 0 &&
287 (free_recent || !(state->flags & kCacheRecent)) && s != current) {
288 cache_size_ -= sizeof(S) + state->arcs.capacity() * sizeof(Arc);
289 delete state;
293 state->flags &= ~kCacheRecent;
326 bool cache_start_; // Is the start state cached?
329 mutable StateId min_unexpanded_state_id_; // minimum never-expanded state Id
330 StateId cache_first_state_id_; // First cached state id
331 S *cache_first_state_; // First cached state
345 // Arcs implemented by an STL vector per state. Similar to VectorState
373 typedef CacheState<A> State;
385 // Use this to make a state iterator for a CacheBaseImpl-derived Fst.
388 // the initial state, so consider implementing a class-specific one.
400 fst_.Start(); // force start state
406 ArcIterator<F>(fst_, u); // force state expansion
427 // define types Arc and State.
432 typedef typename F::State State;
453 const State *state_;