A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/range_8hpp_source.html below:

NCBI C++ ToolKit: include/util/range.hpp Source File

57 template

<

bool

Signed,

class

Position>

64 template

<

class

Position>

75 template

<

class

Position>

86 template

<

class

Position>

95

struct SPositionTraits<float> : SPositionTraitsBySignedness<true, float>

100

struct SPositionTraits<double> : SPositionTraitsBySignedness<true, double>

105

struct SPositionTraits<long double>

106

: SPositionTraitsBySignedness<true, long double>

116

template<class Position>

120

typedef Position position_type;

121

typedef COpenRange<Position> TThisType;

125

: m_From(GetEmptyFrom()), m_ToOpen(GetEmptyToOpen())

128

COpenRange(position_type from, position_type toOpen)

129

: m_From(from), m_ToOpen(toOpen)

134

position_type GetFrom(void) const

138

position_type GetToOpen(void) const

142

position_type GetTo(void) const

144

return GetToOpen()-1;

148

bool Empty(void) const

150

return GetToOpen() <= GetFrom();

152

bool NotEmpty(void) const

154

return GetToOpen() > GetFrom();

158

position_type GetLength(void) const

160

position_type from = GetFrom(), toOpen = GetToOpen();

161

if ( toOpen <= from )

163

position_type len = toOpen - from;

164

if ( SPositionTraits<position_type>::IsNegative(len) )

165

len = GetWholeLength();

170

TThisType& SetFrom(position_type from)

175

TThisType& SetToOpen(position_type toOpen)

180

TThisType& SetTo(position_type to)

182

return SetToOpen(to+1);

184

TThisType& SetOpen(position_type from, position_type toOpen)

186

return SetFrom(from).SetToOpen(toOpen);

188

TThisType& Set(position_type from, position_type to)

190

return SetFrom(from).SetTo(to);

194

TThisType& SetLength(position_type length)

196

_ASSERT(!SPositionTraits<position_type>::IsNegative(length));

197

position_type from = GetFrom();

198

position_type toOpen = from + length;

200

toOpen = GetWholeToOpen();

201

return SetToOpen(toOpen);

204

TThisType& SetLengthDown(position_type length)

206

_ASSERT(length >= 0);

207

position_type toOpen = GetToOpen();

208

position_type from = toOpen - length;

210

from = GetWholeFrom();

211

return SetFrom(from);

215

bool operator==(const TThisType& r) const

217

return GetFrom() == r.GetFrom() && GetToOpen() == r.GetToOpen();

219

bool operator!=(const TThisType& r) const

221

return !(*this == r);

223

bool operator<(const TThisType& r) const

225

return GetFrom() < r.GetFrom() ||

226

(GetFrom() == r.GetFrom() && GetToOpen() < r.GetToOpen());

228

bool operator<=(const TThisType& r) const

230

return GetFrom() < r.GetFrom() ||

231

(GetFrom() == r.GetFrom() && GetToOpen() <= r.GetToOpen());

233

bool operator>(const TThisType& r) const

235

return GetFrom() > r.GetFrom() ||

236

(GetFrom() == r.GetFrom() && GetToOpen() > r.GetToOpen());

238

bool operator>=(const TThisType& r) const

240

return GetFrom() > r.GetFrom() ||

241

(GetFrom() == r.GetFrom() && GetToOpen() >= r.GetToOpen());

246

static position_type GetPositionMin(void)

248

return numeric_limits<position_type>::min();

250

static position_type GetPositionMax(void)

252

return numeric_limits<position_type>::max();

256

static position_type GetWholeFrom(void)

258

return GetPositionMin();

260

static position_type GetWholeToOpen(void)

262

return GetPositionMax();

264

static position_type GetWholeTo(void)

266

return GetWholeToOpen()-1;

268

static position_type GetWholeLength(void)

270

return GetPositionMax();

272

static TThisType GetWhole(void)

274

return TThisType(GetWholeFrom(), GetWholeToOpen());

276

bool IsWholeFrom(void) const

278

return GetFrom() == GetWholeFrom();

280

bool IsWholeTo(void) const

282

return GetToOpen() == GetWholeToOpen();

284

bool IsWhole(void) const

286

return IsWholeFrom() && IsWholeTo();

290

static position_type GetEmptyFrom(void)

292

return GetPositionMax();

294

static position_type GetEmptyToOpen(void)

296

return GetPositionMax();

298

static position_type GetEmptyTo(void)

300

return GetEmptyToOpen()-1;

302

static position_type GetEmptyLength(void)

306

static TThisType GetEmpty(void)

308

return TThisType(GetEmptyFrom(), GetEmptyToOpen());

312

TThisType IntersectionWith(const TThisType& r) const

314

return TThisType(max(GetFrom(), r.GetFrom()),

315

min(GetToOpen(), r.GetToOpen()));

317

TThisType& IntersectWith(const TThisType& r)

319

m_From = max(GetFrom(), r.GetFrom());

320

m_ToOpen = min(GetToOpen(), r.GetToOpen());

323

TThisType operator&(const TThisType& r) const

325

return IntersectionWith(r);

327

TThisType& operator&=(const TThisType& r)

329

return IntersectWith(r);

331

bool IntersectingWith(const TThisType& r) const

333

return IntersectionWith(r).NotEmpty();

336

bool AbuttingWith(const TThisType& r) const

338

if (Empty() || IsWhole() || r.Empty() || r.IsWhole()) {

341

return GetToOpen() == r.GetFrom() || GetFrom() == r.GetToOpen();

345

TThisType& CombineWith(const TThisType& r)

349

m_From = min(m_From, r.GetFrom());

350

m_ToOpen = max(m_ToOpen, r.GetToOpen());

358

TThisType CombinationWith(const TThisType& r) const

362

return TThisType(min(m_From, r.GetFrom()),

363

max(m_ToOpen, r.GetToOpen()));

371

TThisType& operator+=(const TThisType& r)

373

return CombineWith(r);

375

TThisType operator+(const TThisType& r) const

377

return CombinationWith(r);

381

position_type m_From, m_ToOpen;

386

template<class Position>

387

class CRange : public COpenRange<Position>

390

typedef COpenRange<Position> TParent;

391

typedef typename TParent::position_type position_type;

392

typedef CRange<Position> TThisType;

398

CRange(position_type from, position_type to)

399

: TParent(from, to+1)

402

CRange(const TParent& range)

408

TThisType& operator=(const TParent& range)

410

static_cast<TParent&>(*this) = range;

419

typedef CRange<TSeqPos> TSeqRange;

420

typedef CRange<TSignedSeqPos> TSignedSeqRange;

424

template<class Position>

426

CNcbiOstream& operator<<(CNcbiOstream& out, const COpenRange<Position>& range)

428

return out << range.GetFrom() << ".." << range.GetTo();

Include a standard set of the NCBI C++ Toolkit most basic headers.

static bool IsNegative(Position)

static bool IsNegative(Position pos)

#define BEGIN_NCBI_SCOPE

Define ncbi namespace.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4