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

function that updates the entry of the tree only if it exists #9

Open
abdullahemad12 opened this issue Jun 29, 2018 · 0 comments
Open
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed Testing Testing a feature or a function

Comments

@abdullahemad12
Copy link
Owner

abdullahemad12 commented Jun 29, 2018

Task

This should be like the normal update function, however it does not insert a new entry if no entry was found. You should also write tests for this function as well

Interface

/**
  * cranbtree_t*, int, void* -> void
  * MODIFIES: cranbtree_t* 
  * EFFECTS: Updates the object of the entry that has the specified key with the new pointer only if it 
  * exists. 
  * PARAMETERS: 
  * - cranbtree_t* cbt, pointer to the BTree struct
  * - int key: the key of the entry to be updated
  * - void* object: pointer to the object
  * RETURNS: pointer to the old object, or NULL if it does not exist
  */
void* cbt_update_if_exists(cranbtree_t* bt, int key, void* object);

Where to code

You will find a stub for the function in src/cranbtree.c. You should complete this function

hint:

think how this function is different from the original update and how you could reuse existing code

@abdullahemad12 abdullahemad12 added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers Testing Testing a feature or a function labels Jun 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed Testing Testing a feature or a function
Projects
None yet
Development

No branches or pull requests

1 participant