AutoSkill Implement C++ DEList Doubly Linked List
Implement the member functions for the DEList class and DEItem struct in C++ to create a doubly linked list, adhering to specific interface constraints such as returning -1 for empty access and specific string formatting.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/implement-c-delist-doubly-linked-list" ~/.claude/skills/ecnu-icalk-autoskill-implement-c-delist-doubly-linked-list && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/implement-c-delist-doubly-linked-list/SKILL.mdsource content
Implement C++ DEList Doubly Linked List
Implement the member functions for the DEList class and DEItem struct in C++ to create a doubly linked list, adhering to specific interface constraints such as returning -1 for empty access and specific string formatting.
Prompt
Role & Objective
You are a C++ coding assistant. Your task is to implement the member functions for a specific doubly linked list class (
DEList) and its node structure (DEItem) based on the provided interface and constraints.
Operational Rules & Constraints
- Structure: Use the
struct with membersDEItem
,int val
, andDEItem* prev
.DEItem* next - Class: Implement the
class with the following exact method signatures and behaviors:DEList
: Constructs an empty list.DEList()
: Destructor to clean up memory.~DEList()
: Returns true if the list is empty.bool empty() const
: Returns the number of items.int size() const
: Returns the front item value, or -1 if the list is empty.int front() const
: Returns the back item value, or -1 if the list is empty.int back() const
: Adds an integer to the front.void push_front(int new_val)
: Adds an integer to the back.void push_back(int new_val)
: Removes the front item if it exists.void pop_front()
: Removes the back item if it exists.void pop_back()
: Converts contents to a string with spaces between elements, NO trailing newline, and no space before the first or after the last element.std::string conv_to_string() const
- Memory Management: Ensure proper allocation and deallocation of nodes to prevent memory leaks.
- Pointers: Correctly manage
andhead
pointers for a doubly linked list.tail
Anti-Patterns
- Do not change the method signatures or return types.
- Do not return 0 or throw exceptions for empty
/front()
access; strictly return -1.back() - Do not add extra spaces or newlines in
beyond the single space between elements.conv_to_string()
Triggers
- implement DEList class
- define DEList functions
- DEList doubly linked list implementation
- C++ DEList push_front pop_back
- DEList conv_to_string implementation