// INSTRUCTIONS: In many programming languages based on C, comments come in two
// flavors.  A single-line comment begins with two slashes and continues until
// the end of the line:
//
// > this is code // this is a comment
// > this is code again because the comment above ended with the newline
//
// And a multi-line comment begins with a slash-star and continues until the
// next star-slash:
//
// > this is code /* this is a comment, and
// > this is still the same comment,
// > but */ this is code again because the comment ended with the star-slash.
//
// Suppose that you designing an algorithm to check large pieces of source code
// and make sure that they do not end in the middle of a comment.  The best
// possible serial algorithm already runs in linear time, but the check can be
// made even faster for large inputs by using a parallel algorithm, in
// particular a map-reduce algorithm.
//
// A basic map-reduce framework is already provided in `mapReduce.js` and
// `worker.js`.  For the functional correctness points, finish the algorithm by
// implementing the following features below:
//
// * Determine the fields that you would need to store in each monoid element
//   and implement an appropriate constructor for the `MonoidElement` class.
//
// * Determine the identity element of your monoid, and store it in the constant
//   `IDENTITY_ELEMENT`.
//
// * Determine how to convert individual characters from the source code your
//   algorithm is checking to monoid elements (the "map" step), and implement
//   that conversion in the function `encodeAsMonoidElement`.
//
// * Determine how to combine two monoid elements (the "reduce" step), and
//   implement that combination process in the function `combineMonoidElements`.
//
// * Determine how to covert the final monoid element to a boolean (`true` if
//   the source code is okay but `false` if the source code ends in the middle
//   of a comment) and implement that conversion process in the getter `get
//   okay`.
//
// (There is an example monoid that you can mimic implemented in `sum.js`; its
// test cases are in `sum.test.js`.)
//
// As a hint for finding an appropriate monoid, properly commented programs can
// be recognized with a finite state machine (FSM), so, like in class, try
// drawing the FSM and then deriving the syntactic monoid.
//
// Note that the test case inputs are so small that the cost of creating
// threads, communicating between them, and then destroying threads almost
// certainly outweighs the benefits of parallelism, which is why the tests may
// feel a little slow.  You would need much larger inputs to see the benefits of
// multithreading.
//
// Finally, note that Jest is only configured to collect coverage from the main
// thread.  Therefore the code coverage report from the test suite might show
// that some lines of code are not covered if they only ran on a worker thread;
// you can safely ignore those warnings.

// INSTRUCTIONS: Uncomment and implement this class's constructor and
// boolean-valued getter.
class MonoidElement {
  // constructor() {
  // }

  // get okay() {
  //   return false;
  // }
}

// INSTRUCTIONS: Set this constant to a proper identity element.
export const IDENTITY_ELEMENT = new MonoidElement();

// INSTRUCTIONS: Implement this function so that it converts a character from
// the program source code to an appropriate monoid element.
export function encodeAsMonoidElement(character) {
  return new MonoidElement();
}

// INSTRUCTIONS: Implement this function so that it combines two monoid
// elements.
export function combineMonoidElements(left, right) {
  return new MonoidElement();
}