mohitanand001 / underscore_cpp

underscore_cpp
MIT License
7 stars 30 forks source link

Added difference #23

Closed rvmzes closed 5 years ago

rvmzes commented 5 years ago

Hi @farziengineer. I thought it should keep the same order like union.

mohitanand001 commented 5 years ago

Hi, now that you say it I think, the implementation of union should also be changed to a more optimal one, just like you have done for intersection. Also we can assume that the elements in the individual collections are unique (going by the mathematical definition of a set )

rvmzes commented 5 years ago

@farziengineer https://underscorejs.org/#union Computes the union of the passed-in arrays: the list of unique items, in order, that are present in one or more of the arrays.

Sorting won't do it.

mohitanand001 commented 5 years ago

Hi, you have a valid point, but going by the mathematical definition of set/union/intersection/difference we can assume the the order and the frequency of occurrence of a element in the final result does not matter. Thanks.

rvmzes commented 5 years ago

Please check.

mohitanand001 commented 5 years ago

Your PR cannot be merged because of conflicts. First, pull the latest changes and then, try to commit. Thanks.