-
Notifications
You must be signed in to change notification settings - Fork 18
Data structures update #77
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
1e4570d
added lp_polynomial_vector_print
45ada1a
added lp_polynomial_vector_swap
d910734
added lp_polynomial_vector_get_context
9e07eb4
implemented lp_polynomial_vector_copy
5f0e1d4
implemented lp_polynomial_hash_set_remove
a32c130
fixed typo
ee549fb
heap implemented
be8cb97
added lp_polynomial_hash_set_new and lp_polynomial_hash_set_delete.
7920157
added lp_polynomial_hash_set_insert_vector
81d9d42
added some heap functions
cbe565d
added lp_polynomial_vector_push_back_move
33f804d
added lp_variable_order_max and lp_variable_order_min
a0303e3
fixed bugs in new code
a42fdc9
added lp_polynomial_hash_set_insert_move
07fff90
added get_size and at functions for hash_set and heap. Made some para…
dd05c90
added lp_polynomial_heap_push_move
4f5c9ee
fixed typo
d47e55a
added upolynomial_to_polynomial and hash_set_intersection
00cf84b
fixed memory bug in polynomial_heap.c
0e99baa
Merge branch 'master' into data-structures
f000d53
Fixed review comments.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /** | ||
| * Copyright 2015, SRI International. | ||
| * | ||
| * This file is part of LibPoly. | ||
| * | ||
| * LibPoly is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Lesser General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * LibPoly is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License | ||
| * along with LibPoly. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "poly.h" | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| typedef int (*lp_polynomial_heap_compare_f)(const lp_polynomial_t* A, const lp_polynomial_t* B); | ||
|
|
||
| struct lp_polynomial_heap_struct { | ||
| /** The data */ | ||
| lp_polynomial_t** data; | ||
| /** Size of the data */ | ||
| size_t data_size; | ||
| /** Number of set elements */ | ||
| size_t size; | ||
| /** The compare function */ | ||
| lp_polynomial_heap_compare_f cmp; | ||
| }; | ||
|
|
||
| /** Allocates a new heap and constructs it */ | ||
| lp_polynomial_heap_t* lp_polynomial_heap_new(lp_polynomial_heap_compare_f cmp); | ||
|
|
||
| /** Destructs a heap and frees the memory */ | ||
| void lp_polynomial_heap_delete(lp_polynomial_heap_t* heap); | ||
|
|
||
| /** Construct a new heap */ | ||
| void lp_polynomial_heap_construct(lp_polynomial_heap_t* heap, lp_polynomial_heap_compare_f cmp); | ||
|
|
||
| /** Destruct the heap */ | ||
| void lp_polynomial_heap_destruct(lp_polynomial_heap_t* heap); | ||
|
|
||
| /** Returns true if empty */ | ||
| int lp_polynomial_heap_is_empty(const lp_polynomial_heap_t* heap); | ||
|
|
||
| /** Returns the number of elements */ | ||
| size_t lp_polynomial_heap_size(const lp_polynomial_heap_t* heap); | ||
|
|
||
| /** Add polynomial p to the heap. */ | ||
| void lp_polynomial_heap_push(lp_polynomial_heap_t* heap, const lp_polynomial_t* p); | ||
|
|
||
| /** Add polynomial p to the heap. Moves the content of p and p becomes a 0 polynomial. */ | ||
| void lp_polynomial_heap_push_move(lp_polynomial_heap_t* heap, lp_polynomial_t* p); | ||
|
|
||
| /** Add all polynomials from the vector to the heap */ | ||
| void lp_polynomial_heap_push_vector(lp_polynomial_heap_t* heap, const lp_polynomial_vector_t* v); | ||
|
|
||
| /** Removes and returns the top element of the heap, returns NULL if the heap is empty */ | ||
| lp_polynomial_t* lp_polynomial_heap_pop(lp_polynomial_heap_t* heap); | ||
|
|
||
| /** Removes an element from the heap. Returns number of removed polynomials. */ | ||
| int lp_polynomial_heap_remove(lp_polynomial_heap_t* heap, const lp_polynomial_t *p); | ||
|
|
||
| /** Returns the top element without removing it. */ | ||
| const lp_polynomial_t* lp_polynomial_heap_peek(const lp_polynomial_heap_t* heap); | ||
|
|
||
| /** Returns one element */ | ||
| const lp_polynomial_t* lp_polynomial_heap_at(const lp_polynomial_heap_t* heap, size_t n); | ||
|
|
||
| /** Clear the heap. */ | ||
| void lp_polynomial_heap_clear(lp_polynomial_heap_t* heap); | ||
|
|
||
| /** Prints the heap */ | ||
| void lp_polynomial_heap_print(lp_polynomial_heap_t* heap, FILE *); | ||
|
|
||
| #ifdef __cplusplus | ||
| } /* close extern "C" { */ | ||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.