// RaphTimeCommonLib.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#pragma once
#include <iostream>
#include "List.h"
using namespace RaphTime::Common;
int main()
{
List<std::string, int> list;
list.add("one", 1);
list.add("two", 2);
list.add("three", 3);
// Access by index
auto element1 = list.getByIndex(1);
if (element1) {
std::cout << "Element at index 1: " << *element1 << std::endl;
}
else {
std::cout << "Element at index 1 not found." << std::endl;
}
// Access by key
auto element2 = list.getByKey("two");
if (element2) {
std::cout << "Element with key 'two': " << *element2 << std::endl;
}
else {
std::cout << "Element with key 'two' not found." << std::endl;
}
// Remove by index
if (list.removeByIndex(1)) {
std::cout << "Removed element at index 1." << std::endl;
}
else {
std::cout << "Failed to remove element at index 1." << std::endl;
}
std::cout << "After removing index 1, size: " << list.size() << std::endl;
// Remove by key
if (list.removeByKey("three")) {
std::cout << "Removed element with key 'three'." << std::endl;
}
else {
std::cout << "Failed to remove element with key 'three'." << std::endl;
}
std::cout << "After removing key 'three', size: " << list.size() << std::endl;
// Clear the list
list.clear();
std::cout << "After clearing, size: " << list.size() << std::endl;
// Add new elements for iteration example
list.add("four", 4);
list.add("five", 5);
// Iterate over elements using range-based for loop
for (const auto& element : list) {
std::cout << "Element: " << element << std::endl;
}
return 0;
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件

sdragon_163
- 粉丝: 0
最新资源
- 电子商务与现代物流复习资料.doc
- GSM高级网络优化工程师面试总结.doc
- C语言程序设计教材答案.doc
- 分析计算机软件安全检测存在问题及措施.docx
- 华为服务器安装操作系统.docx
- 基于大数据发展分析我国高校财务会计未来趋势.docx
- VMware虚拟化项目设计实施方案V-.docx
- Flet框架实现的浮动按钮展开隐藏按钮组自定义组件
- 广东工业大学C语言实验(上机)任务2015版.doc
- 算法概念程序灵魂——算法.ppt
- 计算机网络安全测验考试附答案.doc
- 信息系统安全产品项目建议书.docx
- 大数据支持市域治理现代化之路.docx
- 2018 年计算机视觉工程师岗位实习工作笔记
- 中南大学微机原理与接口技术期末考试试卷.docx
- 证券网络安全解决实施方案书.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


