LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
getHashOrAdd.m
1function [hashid, sn] = getHashOrAdd(sn, ind, inspace)
2% [HASHID, QN] = GETHASHORADD(QN, IND, INSPACE)
3
4% Copyright (c) 2012-2026, Imperial College London
5% All rights reserved.
6
7if isempty(inspace)
8 hashid = -1;
9 return
10end
11
12% ind: node index
13%ist = sn.nodeToStation(ind);
14isf = sn.nodeToStateful(ind);
15
16if isempty(sn.space{isf})
17 line_error(mfilename,'Station state space is not initialized. Use setStateSpace method.\n');
18end
19
20% resize
21if size(inspace,2) < size(sn.space{isf},2)
22 inspace = [zeros(size(inspace,1),size(sn.space{isf},2)-size(inspace,2)), inspace];
23elseif size(inspace,2) > size(sn.space{isf},2)
24 sn.space{isf} = [zeros(size(sn.space{isf},1),size(inspace,2)-size(sn.space{isf},2)),sn.space{isf}];
25end
26
27hashid = matchrows(sn.space{isf},inspace);
28%hashid=zeros(size(inspace,1),1);
29for j=1:size(inspace,1)
30 % hashid(j,1) = matchrow(sn.space{isf},inspace(j,:));
31 if hashid(j,1) <0
32 sn.space{isf}(end+1,:) = inspace(j,:);
33 hashid(j,1) = size(sn.space{isf},1);
34 end
35end
36end