mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
49 lines
788 B
C++
49 lines
788 B
C++
#pragma once
|
|
|
|
namespace orbis {
|
|
inline namespace utils {
|
|
template <typename T> struct LinkedNode {
|
|
T object;
|
|
LinkedNode *next = nullptr;
|
|
LinkedNode *prev = nullptr;
|
|
|
|
void insertNext(LinkedNode &other) {
|
|
other.next = next;
|
|
other.prev = this;
|
|
|
|
if (next != nullptr) {
|
|
next->prev = &other;
|
|
}
|
|
|
|
next = &other;
|
|
}
|
|
|
|
void insertPrev(LinkedNode &other) {
|
|
other.next = this;
|
|
other.prev = prev;
|
|
|
|
if (prev != nullptr) {
|
|
prev->next = &other;
|
|
}
|
|
|
|
prev = &other;
|
|
}
|
|
|
|
LinkedNode *erase() {
|
|
if (prev != nullptr) {
|
|
prev->next = next;
|
|
}
|
|
|
|
if (next != nullptr) {
|
|
next->prev = prev;
|
|
}
|
|
|
|
prev = nullptr;
|
|
auto result = next;
|
|
next = nullptr;
|
|
return result;
|
|
}
|
|
};
|
|
} // namespace utils
|
|
} // namespace orbis
|