Home | History | Annotate | Download | only in fst

Lines Matching full:state

51 //   void Free(S *state, StateId s);
69 S *state = mru_;
71 state->Reset();
72 return state;
77 void Free(S *state, StateId s) {
81 mru_ = state;
93 // must set the final weight even if the state is non-final to mark it as
104 typedef S State;
106 typedef typename State::Arc Arc;
113 using VectorFstBaseImpl<State>::NumStates;
114 using VectorFstBaseImpl<State>::AddState;
115 using VectorFstBaseImpl<State>::SetState;
150 // Gets a state from its ID; state must exist.
158 // Gets a state from its ID; state must exist.
166 // Gets a state from its ID; return 0 if it doesn't exist.
176 // Gets a state from its ID; add it if necessary.
179 return cache_first_state_; // Return 1st cached state
181 cache_first_state_id_ = s; // Remember 1st cached state
190 return cache_first_state_; // Return 1st cached state
192 while (NumStates() <= s) // Add state to main cache
196 if (cache_first_state_id_ != kNoStateId) { // Forget 1st cached state
216 S *state = VectorFstBaseImpl<S>::GetState(s);
217 return state;
229 S *state = ExtendState(s);
230 state->final = w;
231 state->flags |= kCacheFinal | kCacheRecent | kCacheModified;
234 // AddArc adds a single arc to state s and does incremental cache
238 S *state = ExtendState(s);
239 state->arcs.push_back(arc);
241 ++state->niepsilons;
244 ++state->noepsilons;
246 const Arc *parc = state->arcs.empty() ? 0 : &(state->arcs.back());
248 state->flags |= kCacheModified;
256 // Adds a single arc to state s but delays cache book-keeping.
257 // SetArcs must be called when all PushArc calls at a state are
260 S *state = ExtendState(s);
261 state->arcs.push_back(arc);
264 // Marks arcs of state s as cached and does cache book-keeping after all
267 S *state = ExtendState(s);
268 vector<Arc> &arcs = state->arcs;
269 state->niepsilons = state->noepsilons = 0;
275 ++state->niepsilons;
277 ++state->noepsilons;
280 state->flags |= kCacheArcs | kCacheRecent | kCacheModified;
289 S *state = ExtendState(s);
290 state->arcs.reserve(n);
294 S *state = ExtendState(s);
303 state->arcs.resize(arcs.size() - n);
305 state->flags |= kCacheModified;
309 S *state = ExtendState(s);
310 state->niepsilons = 0;
311 state->noepsilons = 0;
312 state->arcs.clear();
314 state->flags |= kCacheModified;
317 // Is the start state cached?
324 // Is the final weight of state s cached?
326 const S *state = CheckState(s);
327 if (state && state->flags & kCacheFinal) {
328 state->flags |= kCacheRecent;
335 // Are arcs of state s cached?
337 const S *state = CheckState(s);
338 if (state && state->flags & kCacheArcs) {
339 state->flags |= kCacheRecent;
347 const S *state = GetState(s);
348 return state->final;
352 const S *state = GetState(s);
353 return state->arcs.size();
357 const S *state = GetState(s);
358 return state->niepsilons;
362 const S *state = GetState(s);
363 return state->noepsilons;
368 const S *state = GetState(s);
370 data->narcs = state->arcs.size();
371 data->arcs = data->narcs > 0 ? &(state->arcs[0]) : 0;
372 data->ref_count = &(state->ref_count);
379 // Update number of known states taking in account the existence of state s.
385 // Find the mininum never-expanded state Id
410 S* state = VectorFstBaseImpl<S>::GetState(s);
411 if (cache_size_ > cache_target && state->ref_count == 0 &&
412 (free_recent || !(state->flags & kCacheRecent)) && s != current) {
413 cache_size_ -= sizeof(S) + state->arcs.capacity() * sizeof(Arc);
414 allocator_->Free(state, s);
418 state->flags &= ~kCacheRecent;
456 static const uint32 kCacheModified = 0x0008; // Mark state as modified
464 mutable bool cache_start_; // Is the start state cached?
467 mutable StateId min_unexpanded_state_id_; // minimum never-expanded state Id
468 StateId cache_first_state_id_; // First cached state id
469 S *cache_first_state_; // First cached state
484 state. Similar to VectorState
515 typedef CacheState<A> State;
522 CacheImpl(const CacheImpl<State> &impl) : CacheBaseImpl<State>(impl) {}
525 void operator=(const CacheImpl<State> &impl); // disallow
529 // Use this to make a state iterator for a CacheBaseImpl-derived Fst,
530 // which must have type 'State' defined. Note this iterator only
531 // returns those states reachable from the initial state, so consider
538 typedef typename F::State State;
539 typedef CacheBaseImpl<State> Impl;
547 fst_.Start(); // force start state
553 // force state expansion
587 // which must have types 'Arc' and 'State' defined.
593 typedef typename F::State State;
595 typedef CacheBaseImpl<State, C> Impl;
623 const State *state_;
630 // which must have types 'Arc' and 'State' defined.
636 typedef typename F::State State;
640 typedef CacheBaseImpl<State, C> Impl;
665 state_->flags |= CacheBaseImpl<State, C>::kCacheModified;
731 State *state_;