MCPcopy Create free account
hub / github.com/Gecode/gecode / slice

Method slice

gecode/kernel/data/array.hpp:955–971  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

953
954 template<class Var>
955 typename ArrayTraits<VarArgArray<Var>>::ArgsType
956 VarArray<Var>::slice(int start, int inc, int maxN) {
957 assert(n==0 || start < n);
958 if (n==0 || maxN<0)
959 maxN = n;
960 int s;
961 if (inc == 0)
962 s = n-start;
963 else if (inc > 0)
964 s = (n-start)/inc + ((n-start) % inc == 0 ? 0 : 1);
965 else
966 s = (start+1)/-inc + ((start+1) % -inc == 0 ? 0 : 1);
967 typename ArrayTraits<VarArgArray<Var>>::ArgsType r(std::min(maxN,s));
968 for (int i=0; i<r.size(); i++, start+=inc)
969 r[i] = x[start];
970 return r;
971 }
972
973 template<class Var>
974 forceinline typename VarArray<Var>::iterator

Callers

nothing calls this directly

Calls 2

minFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected