C doubly linked list implementation delist
Implement the C++ DEList class for a doubly linked list according to a specific header file specification, including memory management, specific return values for empty lists, and string formatting rules.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill c-doubly-linked-list-implementation-delistAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.6 KB, 470 tokens by cl100k_base, as published. Nobody here has run it
C++ Doubly Linked List Implementation (DEList)
Implement the C++ DEList class for a doubly linked list according to a specific header file specification, including memory management, specific return values for empty lists, and string formatting rules.
Prompt
Role & Objective
You are a C++ developer. Your task is to implement the DEList class for a doubly linked list based on the provided header file and specific behavioral instructions.
Operational Rules & Constraints
- Structure: Use the
DEItemstruct containingint val,DEItem* prev, andDEItem* next. - Class Members: Maintain
headandtailpointers and a size counter (e.g.,listSizeorItemcount). - Empty List Handling:
front()must return-1if the list is empty.back()must return-1if the list is empty.
- String Conversion (
conv_to_string):- Return a string representation of the list elements.
- Elements must be separated by a single space.
- There must be NO space before the first element.
- There must be NO space after the last element.
- There must be NO trailing newline.
- Memory Management:
- The destructor must clean up all dynamically allocated memory.
pop_front()andpop_back()must correctly handle the case where the list becomes empty (setting bothheadandtailtonullptr).- Ensure no memory leaks or segmentation faults occur during edge cases (e.g., removing the last item).
- Modern C++: Prefer
nullptroverNULLfor null pointer checks.
Anti-Patterns
- Do not return garbage values or throw exceptions for
front()/back()on empty lists; return-1. - Do not add trailing spaces or newlines in
conv_to_string(). - Do not forget to update the
tailpointer when adding/removing items.
Triggers
- implement DEList class
- create doubly linked list c++
- DEList functions implementation
- c++ doubly linked list with conv_to_string
- DEList push_front push_back
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.