arrayinterface's People
Forkers
ciarrapetersarrayinterface's Issues
Push() purpose statement intention?
Do you intend for push() to "Add the given object to the next available index" OR "at the end of the array". For example, in your test_remove() test, you make an Array of size 7, then only add an element at index 3. What would be the "next available index"? Would it be 0 (presumably an empty slot in the array), 4 (following the element you just placed at 3), or 7 (the size of the array). The test and spec seem to conflict a bit.
/**
* @brief Tests the remove function for Array
*/
void test_remove() {
Array* arr = new Array(7);
Object* obj = new Object();
arr->set(obj, 3);
assert(obj->equals(arr->remove(3)));
assert(arr->get(3) == NULL);
delete(obj);
delete(arr);
}
Thank you!
Add index of to array api
Would you be able to add an index_of() method to your array api? We think this is a useful method that will help us with other parts of the assignment
Could you change the primitive type wrappers to array classes?
In class we talked about how having array types like intArray, floatArray, boolArray are faster and probably a better way to handle primitives instead of wrappers. Do you think you could implement these instead?
Basically these would look just like the Array class but instead of having parameters as type Object, they would be of type int (or other primitive) where appropriate.
Thanks!
Need support for adding primitive types to Array
Since your Array is an Array of Objects, we will not be able to add primitive types (int, float, bool) to the Array otherwise.
Thank you!
Design spec for array
Hey sorry, we just noticed this as we were reading through the assignment for what we thought would be one last time. It says Arrays should grow when values are pushed back, and otherwise support reads and writes.
To fix this, since you guys are going for a fixed size array api, we think you could just add a push() method that takes an object to add. We can then just call resize and set to push the object back and grow the array. Everything else would stay the same. What do you guys think?
What happens if we try to push an element on a full array?
What happens if we try to push an element on a full array?
For example:
array = [object1, object2, object3]
if we call array->push(object4), should we allocate more space by resize()? Or are you trying to make this a fixed size array?
Compiler errors in test-array.cpp
Thanks for all the updates! We just tried to rerun the tests with our new implementation but there are compiler errors with the new code. Could you please fix them?
Thanks!
Access to repo to make PR
We modified a bit of the code to fix some compiler issues in the test-array.cpp file. We also ended up changing the interface a bit for the primitive Arrays to inherit from Object instead of Array. This is because we found we would still need to use primitive Wrappers if we inherited from Array, since Array uses Objects.
We tried checking out a branch and pushing it to this repo to make a PR, but it still says:
Would you be able to give us access to the repo so you won't have to write out all this code if you agree with our changes?
Thank you!
Delete(arr) breaking tests?
In your tests, you delete the array variables that you create:
void test_constructor_length() {
Array* arr = new Array(20);
assert(arr != NULL);
assert(arr->length() == 20);
delete(arr);
}
This is causing a malloc error when we try to run the tests. Would you be able to explain why you included the delete in there?
Thank you!
APIs to implement
These repositories contain the APIs you should implement
- Queue
https://github.com/hakjoonlee/CS4500-A1P2.git
- Map
https://github.com/TomPeng19971208/CS4500_A1_Part2.git
- Array
Add hash and equals to Array.h API
Could you please add the hash and equals methods to the Array API?
* @brief Gets the hash value for this array (and sets if unset).
*
* @return a size_t representing the hash value
*/
size_t hash();
/**
* @brief determines if this array is same as the other one.
*
* @param other The other object
*
* @return True if equal, false if not
*/
bool equals(Object* other);
We tried making a pull request, but it looks like we don't have access to your repo.
copy constructor for array
What do you mean by deep copy?
These tests are failing rightfully, but I'm not sure if they're proper tests...
t_false(a4->get(0)->equals(a));
t_false(a4->get(1)->equals(b));
t_false(a4->get(2)->equals(a_obj));
They are followed by reverse tests...
t_true(a4->get(0)->equals(a));
t_true(a4->get(1)->equals(b));
t_true(a4->get(2)->equals(a_obj));
t_true(a4->get(3)->equals(b));
index() - unclear desired functionality
t_true(a3->index(a_obj) == 2); // this fails because a is stored at 0 and is technically equal to a_obj
Is this an intended failure?
Can't check equality
We are having problems writing the equals() method since the array is initialized with nullptrs. We can technically check that a value is a nullptr, but then when we actually try to get and return that value, we can't access it and it seg faults. We can't set the array values to be something like 0, '\0' or any other dummy value, etc. as those are not Object* types, or even a new Object() since each default object will be different for each new array initialized.
bool equals(Object* other) {
if (other == nullptr) return false;
Array* l = dynamic_cast<Array*>(other); // if it fails, returns null ptr. if s is null, it was not a string, therefore the two objects are not equal
if (l == nullptr) return false;
// check size first, if they are not the same length, then they are not equal
if (l->length() != size_) {
return false;
}
bool result = true;
// loop through all the values in the given array and make sure they are the same as this array's values
for (int i = 0; i < l->size_; i++) {
std::cout << "inside loop: " << "\n";
Object* this_object = get(i);
Object* other_object = l->get(i);
result = result && this_object->equals(other_object);
}
return result;
}
Do you have any ideas/intentions when you made it? Or can you add some change so that it behaves more like a list and that way we can guarantee there won't be random empty spots.
Set() method Question
The purpose statement for set does not make sense. Why would it be putting the index to the given object? Is set not supposed to just replace the object at the given index with the given object?
Thank you!
Compiler Errors
Ya'll have 19 compiler errors. Could you please go through and fix them? It looks like you might be missing an includes statement for "assert", which is most of your errors.
Thank you!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.