Project

General

Profile

Feature #1692

Suggestion: Add "JumpTo" function to prime iterators

Added by John Abbott over 1 year ago. Updated 2 months ago.

Status:
In Progress
Priority:
Normal
Assignee:
-
Category:
Improving
Target version:
Start date:
05 Aug 2022
Due date:
% Done:

10%

Estimated time:
Spent time:

Description

Consider adding a JumpTo mem fn to iterators (for prime numbers)

  PrimeSeq pseq;
  pseq.myJumpTo(1000000);
  cout << *pseq << end;  // print a prime number close to 1000000
  ++pseq; // advance to next prime number... etc

If we do this, it may make PrimeSeqForCRT redundant [check!]


Related issues

Related to CoCoALib - Design #1787: Iterator design: compatible with C++STL? Advancing beyond end?In Progress2024-03-07

History

#1 Updated by John Abbott over 1 year ago

I implemented a prototype PrimeSeq1ModN class for a student, and he needed something like a JumpTo function.
So I implemented one... it wasn't too hard, and seems like it could be useful for other prime iterators.

It might be nice to be able to remove PrimeSeqForCRT which is a bit of an oddity.
Perhaps PrimeSeq ctor could have an optional arg when used for CRT? ...to avoid
having to call myJumpTo?

#2 Updated by John Abbott over 1 year ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

What should the mem fn be called?
Current prototype calls it JumpTo, so that a mem fn call would look like pseq.JumpTo(n).
This does not follow the rule that mem fns have names beginning with my or Iam.

What name should we use?

#3 Updated by John Abbott 2 months ago

  • Target version changed from CoCoALib-0.99850 to CoCoALib-0.99900

#4 Updated by John Abbott about 2 months ago

  • Related to Design #1787: Iterator design: compatible with C++STL? Advancing beyond end? added

Also available in: Atom PDF