Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differentiation of operations regarding operands' preservation #15

Open
neithernut opened this issue Aug 27, 2014 · 9 comments
Open

Differentiation of operations regarding operands' preservation #15

neithernut opened this issue Aug 27, 2014 · 9 comments

Comments

@neithernut
Copy link
Member

I just relized that we have to differentiate whether an operation should preserve the previous operands or not.
Always preserving the operands of an operation has a huge performance impact, which we did not consider when defining the interface. (We're speaking O(log(n)) vs. O(n) for merges)
If we'd write the lib in C++, we would simply create overloads using move-semantics to differentiate both cases, but as the lib will be C-code, we should discuss how to represent non-preservative versions of the operations in our interface (e.g. as additional functions).

@matthiasbeyer
Copy link
Member

We could simply add more functions, having a _np postfix.

If I understand things right, we will add functions which allocate new objects instead of altering old ones, right?


From my understanding, this has only to be implemented for some functions:

  • r_set_union()
  • r_set_intersection()
  • r_set_xor()
  • r_set_select()
  • r_set_exclude()

And it also relates to the AVL implementation, as the AVL Tree needs features which allow to revert such changes.

But, after reviewing the code again:

r_set_union() Takes three arguments: A destination, a first source and a second one. So we basically already have this behaviour, as if we pass three different sets, we can revert the 'union' change simply by removing the destination set. The same goes for the other mentioned functions.

Or am I misunderstanding something?

@matthiasbeyer
Copy link
Member

Relates to #12

@neithernut
Copy link
Member Author

The second operand will currently be unaffected in every case. For unios this may result in copying ever single item in that operand, which may be unneccessary.
Thus, we should have functions which destroy/consume the second operand.

@matthiasbeyer
Copy link
Member

👍

How to?

@neithernut
Copy link
Member Author

Same function, but with the last set-parameter being non-const and with some suffix ("_nc" for "Non Const")?

@matthiasbeyer
Copy link
Member

Maybe "_d" for "destructive"?

@neithernut
Copy link
Member Author

Maybe.
Or "_c" for "consuming"?

@TheNeikos
Copy link
Contributor

👍 for consuming

@matthiasbeyer
Copy link
Member

👍

@matthiasbeyer matthiasbeyer modified the milestone: v0.0.1 Sep 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants