* @function FeatureVector.prototype.toState * @description 设置新状态。 * @param {string} state - 状态。
(state)
| 202 | * @param {string} state - 状态。 |
| 203 | */ |
| 204 | toState(state) { |
| 205 | if (state === State.UPDATE) { |
| 206 | switch (this.state) { |
| 207 | case State.UNKNOWN: |
| 208 | case State.DELETE: |
| 209 | this.state = state; |
| 210 | break; |
| 211 | case State.UPDATE: |
| 212 | case State.INSERT: |
| 213 | break; |
| 214 | } |
| 215 | } else if (state === State.INSERT) { |
| 216 | switch (this.state) { |
| 217 | case State.UNKNOWN: |
| 218 | break; |
| 219 | default: |
| 220 | this.state = state; |
| 221 | break; |
| 222 | } |
| 223 | } else if (state === State.DELETE) { |
| 224 | switch (this.state) { |
| 225 | case State.INSERT: |
| 226 | // the feature should be destroyed |
| 227 | break; |
| 228 | case State.DELETE: |
| 229 | break; |
| 230 | case State.UNKNOWN: |
| 231 | case State.UPDATE: |
| 232 | this.state = state; |
| 233 | break; |
| 234 | } |
| 235 | } else if (state === State.UNKNOWN) { |
| 236 | this.state = state; |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | /** |
| 241 | * |