problemscpp
A collection of my answers to algorithm problems in c++.
Public 成员函数 | Private 属性 | 所有成员列表
leetcode::design_parking_system::ParkingSystem类 参考

#include <leetcode.h>

Public 成员函数

 ParkingSystem (int big, int medium, int small)
 Initializes object of the ParkingSystem class. 更多...
 
bool addCar (int carType)
 Checks whether there is a parking space of carType for the car that wants to get into the parking lot. 更多...
 

Private 属性

int big
 The number of slots for big parking space 更多...
 
int medium
 The number of slots for medium parking space 更多...
 
int small
 The number of slots for small parking space 更多...
 

详细描述

在文件 leetcode.h2247 行定义.

构造及析构函数说明

◆ ParkingSystem()

leetcode::design_parking_system::ParkingSystem::ParkingSystem ( int  big,
int  medium,
int  small 
)

Initializes object of the ParkingSystem class.

参数
bigThe number of slots for big parking space
mediumThe number of slots for medium parking space
smallThe number of slots for small parking space

在文件 leetcode.cpp6023 行定义.

6024 : big(big), medium(medium), small(small) {}
int medium
The number of slots for medium parking space
Definition: leetcode.h:2249
int big
The number of slots for big parking space
Definition: leetcode.h:2248
int small
The number of slots for small parking space
Definition: leetcode.h:2250

成员函数说明

◆ addCar()

bool leetcode::design_parking_system::ParkingSystem::addCar ( int  carType)

Checks whether there is a parking space of carType for the car that wants to get into the parking lot.

参数
carTypecarType can be of three kinds: big, medium, or small, which are represented by 1, 2, and 3 respectively. A car can only park in a parking space of its carType.
返回
If there is no space available, return false, else park the car in that size space and return true.

在文件 leetcode.cpp6026 行定义.

6026 {
6027 switch(carType) {
6028 case 1: {
6029 if(big > 0) {
6030 big--;
6031 return true;
6032 }
6033 return false;
6034 }
6035 case 2: {
6036 if(medium > 0) {
6037 medium--;
6038 return true;
6039 }
6040 return false;
6041 }
6042 case 3: {
6043 if(small > 0) {
6044 small--;
6045 return true;
6046 }
6047 return false;
6048 }
6049 default: return false;
6050 }
6051 }

引用了 big, medium , 以及 small.

类成员变量说明

◆ big

int leetcode::design_parking_system::ParkingSystem::big
private

The number of slots for big parking space

在文件 leetcode.h2248 行定义.

被这些函数引用 addCar().

◆ medium

int leetcode::design_parking_system::ParkingSystem::medium
private

The number of slots for medium parking space

在文件 leetcode.h2249 行定义.

被这些函数引用 addCar().

◆ small

int leetcode::design_parking_system::ParkingSystem::small
private

The number of slots for small parking space

在文件 leetcode.h2250 行定义.

被这些函数引用 addCar().


该类的文档由以下文件生成: