This is lab2 report.
(2) Dynamic array
• Add a new element (lst.add(3)) • Set an element with specific index / key (lst.set(1, 3)) if applicable. • Remove an element by (lst.remove(3)):
- index for lists
- key for dictionaries - value for sets value
• Access:
- size (lst.size())
- is member (lst.member(3))
- reverse (lst.reverse() (if applicable)
• Conversion from/to built-in list :
- from_list (lst.from_list([12, 99, 37]))
- to_list (lst.to_list())
• Filter data structure by specific predicate (lst.filter(is_even)) • Map1 structure by specific function (lst.map(increment)) • Reduce2 – process structure elements to build a return value by specific functions(lst.reduce(sum)) • Data structure should be an iterator3 in Python style • Data structure should be a monoid and implement empty and concat methods
Dynamic_array.py
-- implementation ofDynamic_array
class withAdd_a_new_element
、Remove
etc.Dynamic_array_test.py
-- unit and PBT tests forDynamic_array
.
- map(f)
- add(item)
- find(key)
- remove(key)
- size( )
- to_list( )
- from_list(a)
- filter(p)
- map(f)
- reduce(f, initial_state)
- empty( )
- concat(dict)
- get(key)
- member(key)
- next( )
- iter( )
- Fan Yuxin ([email protected]) -- Dict_mutable.py
- Wen Wenchao([email protected]) -- Dict_mutable.py
- Fan Yuxin uploaded
Dynamic_array_test.py
. - 13.04.2022 - 1
- Wen Wenchao uploaded
Dynamic_array.py
. - 11.04.2022 - 0
- Initial
We create an Entry class to represent an element in the dictionary. Hash maps are used to store and find elements and open addressing is used to handle conflicts. The internal hash table has a table length of 1000.
- Advantages:
- Support automated testing
- Secondary development is convenient
- Organize test cases together by class
- Disadvantages:
- Must be written in TestCase subclass
- Must write test method
- Difficult to expand
- Advantages:
- Check with automatically generated input data to ensure enough test cases
- Allows developers to increase test coverage and effectively save time
- Disadvantages:
- Not covering all examples