使用 Python 内置的 defaultdict
,我们可以很容易的定义一个树形数据结构:
def tree(): return defaultdict(tree)
就是这样!
#!/usr/bin/env python3 | |
# Copyright (C) 2021 Xidorn Quan | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Affero General Public License as | |
# published by the Free Software Foundation, either version 3 of the | |
# License, or (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, |
#!/bin/bash | |
SERIAL="00000000" | |
echo "Looking for device with serial $SERIAL..." | |
for d in /sys/bus/usb/devices/*-*; do | |
if [[ -f "$d/serial" ]]; then | |
serial=$(<"$d/serial") | |
if [[ "$serial" = "$SERIAL" ]]; then | |
device="$(basename $d)" |
diff -ur a/CPP/7zip/Archive/Zip/ZipItem.cpp b/CPP/7zip/Archive/Zip/ZipItem.cpp | |
--- a/CPP/7zip/Archive/Zip/ZipItem.cpp 2016-02-02 03:50:10.000000000 +1100 | |
+++ b/CPP/7zip/Archive/Zip/ZipItem.cpp 2023-08-15 23:19:44.862769098 +1000 | |
@@ -1,6 +1,7 @@ | |
// Archive/ZipItem.cpp | |
#include "StdAfx.h" | |
+#include <iconv.h> | |
#include "../../../../C/CpuArch.h" |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <CoreServices/CoreServices.h> | |
#include "directory_icon.h" | |
int setDirectoryIcon(const char *dirName, const char *iconData, size_t iconSize) | |
{ | |
const int kResidIcon = -16455; | |
const OSType kRsrcType = 'icns'; |
使用 Python 内置的 defaultdict
,我们可以很容易的定义一个树形数据结构:
def tree(): return defaultdict(tree)
就是这样!
#!/usr/bin/env python3 | |
import plistlib | |
import sqlite3 | |
import uuid | |
from collections import defaultdict | |
from datetime import datetime | |
from typing import NamedTuple | |
from urllib.parse import unquote |
#include <iostream> | |
using namespace std; | |
template<typename T> | |
class Complex { | |
private: | |
T m_real; | |
T m_imag; | |
public: | |
Complex<T>(T real=0.0, T imag=0.0) |
Copyright (c) 2012 Xidorn Quan | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in |
#ifndef RBTREE_RBTREE_H_ | |
#define RBTREE_RBTREE_H_ | |
#include <cstddef> | |
#include <cassert> | |
#include <utility> | |
namespace upsuper { | |
namespace learning { |
#!/usr/bin/env python3 | |
# Copyright (C) 2021 Xidorn Quan | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Affero General Public License as | |
# published by the Free Software Foundation, either version 3 of the | |
# License, or (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, |