| 685 | } |
| 686 | |
| 687 | static SIValue *Proc_SPpathsStep |
| 688 | ( |
| 689 | ProcedureCtx *ctx |
| 690 | ) { |
| 691 | ASSERT(ctx->privateData != NULL); |
| 692 | |
| 693 | SinglePairCtx *single_pair_ctx = ctx->privateData; |
| 694 | WeightedPath p; |
| 695 | |
| 696 | if(single_pair_ctx->path_count == 0) { |
| 697 | if(array_len(single_pair_ctx->array) == 0) return NULL; |
| 698 | |
| 699 | p = array_pop(single_pair_ctx->array); |
| 700 | } else if(single_pair_ctx->path_count == 1) { |
| 701 | p = single_pair_ctx->single; |
| 702 | if(p.path == NULL) return NULL; |
| 703 | |
| 704 | single_pair_ctx->single.path = NULL; |
| 705 | } else { |
| 706 | WeightedPath *pp = Heap_poll(single_pair_ctx->heap); |
| 707 | if(pp == NULL) return NULL; |
| 708 | |
| 709 | p = *pp; |
| 710 | rm_free(pp); |
| 711 | } |
| 712 | |
| 713 | if(single_pair_ctx->yield_path) { |
| 714 | *single_pair_ctx->yield_path = SI_Path(p.path); |
| 715 | Path_Free(p.path); |
| 716 | } |
| 717 | if(single_pair_ctx->yield_path_weight) *single_pair_ctx->yield_path_weight = SI_DoubleVal(p.weight); |
| 718 | if(single_pair_ctx->yield_path_cost) *single_pair_ctx->yield_path_cost = SI_DoubleVal(p.cost); |
| 719 | |
| 720 | return single_pair_ctx->output; |
| 721 | } |
| 722 | |
| 723 | static ProcedureResult Proc_SPpathsFree |
| 724 | ( |