Skip to content

Commit

Permalink
resolved a bug where zero nodes were created in the beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
aveldan committed Jul 6, 2024
1 parent 8aac0d1 commit 1798973
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/classes/list/skip_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ template <typename T> class skip_list {
gen += generate_edge("root", "NULL", m_level+1);
for(int i=m_level;i>=0;i--){
std::shared_ptr<node> head = root;
std::string prev_val;
head = head->next[i];
std::string prev_val = "root";
std::string head_key;
while(head){
if(std::is_same_v<T, std::string>){
Expand All @@ -289,11 +290,7 @@ template <typename T> class skip_list {
S.insert(head_key);
gen += generate_node(head_key, i);
}
if(head != root){
gen += generate_edge(prev_val, head_key, i);
} else {
gen += generate_edge("root", head_key, i);
}
gen += generate_edge(prev_val, head_key, i);
prev_val = head_key;
head = head->next[i];
}
Expand Down

0 comments on commit 1798973

Please sign in to comment.